当前位置:网站首页>1155: 字符串比较 多实例
1155: 字符串比较 多实例
2022-04-21 09:06:00 【谦QIAN】
1155: 字符串比较 多实例
题目描述
比较字符串大小,但比较的规则不同字典序规则。字符比较新规则如下:A < a < B < b < ………… < Z < z。
输入
输入数据包含多个测试实例,每个测试实例占两行,每一行有一个字符串(只包含大小写字母, 长度小于10000)。
输出
如果第一个字符串小于第二个,输出YES,否则,输出NO。
注意:A < a < B < b < ………… < Z < z。
样例输入 Copy
abc
Bbc
Ab
a
ABcef
ABce
样例输出 Copy
YES
YES
NO
来源/分类
#include<stdio.h>
#include<string.h>
#define MAX 10000
/* 字符串比较A < a < B < b < ………… < Z < z。 小写的是奇数 大写的是偶数 */
int main(){
char str1[MAX],str2[MAX];
while(scanf("%s%s",&str1,&str2)!=EOF){
for(int i=0;str1[i]!='\0';i++){
if(str1[i]>='a'&&str1[i]<='z') {
//将小写字符改为ASKII码为1,3,5的字符
str1[i]=(str1[i]-'a')*2+1;
}
if(str1[i]>='A'&&str1[i]<='Z') {
//将小写字符改为ASKII码为0,2,4的字符
str1[i]=(str1[i]-'A')*2;
}
}
for(int i=0;str2[i]!='\0';i++){
if(str2[i]>='a'&&str2[i]<='z') {
str2[i]=(str2[i]-'a')*2+1;
}
if(str2[i]>='A'&&str2[i]<='Z') {
str2[i]=(str2[i]-'A')*2;
}
}
if(strcmp(str1,str2)<0) printf("YES\n");
else printf("NO\n");
}
return 0;
}
版权声明
本文为[谦QIAN]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44500344/article/details/107896092
边栏推荐
- SQL is a general fuzzy query statement. Query table T and seq of table t2 are conditions. How can fuzzy query match multiple characters of SEQ of table t2?
- Map Object WeakMap
- SurfaceView高性能绘制(四)代码实践篇-绘制多张图片
- Flink的api入门案例
- 某系统拥有N个进程,总共7个资源,每个进程需要3个资源,问N数量最多为多少不会死锁?(附解析)
- 垃圾回收机制
- PageRank-案例-机场
- Surfaceview high performance rendering (IV) code practice - drawing multiple pictures
- What is the product power of the new modern paristi, a joint venture 7-seat SUV with large displacement?
- BUUCTF[ACTF2020 新生赛]Include
猜你喜欢
随机推荐
OpenCV——分离颜色通道,图像对比度,亮度调整,离散傅里叶变换(10)
Controlled and uncontrolled components
BUUCTF[ACTF2020 新生赛]Include
Penetration practice - no echo rce thinkphp5 getshell
中国移动的用户ARPU重新进入上升通道,员工薪酬也稳步上涨
My blog navigation directory (constantly sorting and updating...)
[GYCTF2020]Blacklist
2022年上海市安全员C证考试模拟100题及模拟考试
CC00019.CloudJenkins—————————————
Characteristics of interactive multimedia applications
2022 t elevator repair test questions and online simulation test
Uniapp hot update and full package update
电脑常用快捷键+常用Dos命令
In 2017, I also started to write CSDN blog (Sina Netease moved to CSDN)
批量处理数据对比(<foreach>标签和sqlsession)
Latest system vulnerability -- omero Web cross site scripting vulnerability
[CTF. Show. Reverse] moon cake cup RE1_ Northwest Wangxiang, re2_ Homing, RE3_ If there is no month
2022年主要的编程语言及应用
ShardingSphere简介
CC00026.CloudJenkins—————————————




![[GYCTF2020]Blacklist](/img/23/14236d426700925f2da86119b2e4f7.png)




