AcWing 768. 忽略大小写比较字符串大小
原题链接
简单
作者:
Value
,
2020-09-05 08:26:26
,
所有人可见
,
阅读 303
#include <iostream>
using namespace std;
void to(string &s){
for(int i = 0; i < s.size(); i ++ ){
if(s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
}
}
int main(){
string s1, s2; getline(cin, s1), getline(cin, s2);
to(s1), to(s2);
int i, j;
i = j = 0;
bool flag = false;
while(i < s1.size() && j < s2.size()){
if(s1[i] > s2[j]){
cout << ">" << endl;
flag = true;
break;
}else if(s1[i] < s2[j]){
cout << "<" << endl;
flag = true;
break;
}else i ++ , j ++ ;
}
if(!flag){
if(s1.size() == s2.size()) cout << "=" << endl;
else if(i == s1.size()) cout << "<" << endl;
else cout << ">" << endl;
}
return 0;
}