CodeForces 112 A.Petya and Strings(水~)
来源:互联网 发布:有道云笔记数据恢复 编辑:程序博客网 时间:2024/06/05 18:24
Description
给出两个只有大小写字母的字符串a和b,问在不考虑字母的大小写情况下两个字符串的字典序大小
Input
两个等长的字符串a和b,串长不超过100
Output
如果a的字典序小于b则输出-1,等于则输出0,大于则输出1
Sample Input
aaaa
aaaA
Sample Output
0
Solution
水题,把两个字符串全部转化为小写字母后再比较即可
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;typedef pair<int,int>P;const int INF=0x3f3f3f3f,maxn=100001;char deal(char c){ if(c>='A'&&c<='Z')return c-'A'+'a'; return c;}char a[maxn],b[maxn];int main(){ while(~scanf("%s%s",a,b)) { int n=strlen(a); for(int i=0;i<n;i++) a[i]=deal(a[i]),b[i]=deal(b[i]); printf("%d\n",strcmp(a,b)); } return 0;}
阅读全文
0 0
- CodeForces 112 A.Petya and Strings(水~)
- codeforces 112A Petya and Strings
- Codeforces 112A-Petya and Strings(实现)
- 【CodeForces】A. Petya and Strings
- Problem--112A--Codeforces--A. Petya and Strings
- 112A - Petya and Strings
- 112A - Petya and Strings
- A. Petya and Strings
- CF:112A.Petya and Strings
- CF 112A Petya and Strings
- Codeforces刷题之路——112A Petya and Strings
- 【string比较】#85 A. Petya and Strings
- Codeforces 66A:Petya and Java(水题)
- 【Codeforces】66A - Petya and Java(模拟)
- Petya and Strings
- Coderforces Petya and Strings
- 【CodeForces】[66A]Petya and Java
- Codeforces 66A Petya and Java
- Oracle 存储提纲(stored outline)
- 指针的入门程序试题
- android AlarmManager详解,Alarm的设定和取消。
- 关于xampp安装需要注意的问题
- Java日记_17.9.01——点击按钮后,键盘监听失效的原因与解决办法
- CodeForces 112 A.Petya and Strings(水~)
- QT设置环境变量QWS_DISPLAY
- linux内核模块编译
- Spark 自带demo学习日志
- [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress Cloning into 'master
- LeetCode
- 实现一个单例模式的类,要求线程安全
- 653. Two Sum IV
- PAT_A 1048. Find Coins (25)