768. 忽略大小写比较字符串大小
作者:
不想考试
,
2024-11-23 15:34:13
,
所有人可见
,
阅读 1
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a[100],b[100];
fgets(a,100,stdin);
fgets(b,100,stdin);//fgets会把回车也读入
//cout << strlen(a) << ' ' << strlen(b);
if(a[strlen(a) - 1] =='\n') a[strlen(a) - 1] = 0;//去掉末尾回车
if(b[strlen(b) - 1] =='\n') b[strlen(b) - 1] = 0;//去掉末尾回车
for(int i = 0;a[i];i ++)
if(a[i] >= 'A' && a[i] <= 'Z')
a[i] += 32;
for(int i = 0;b[i];i ++)
if(b[i] >= 'A' && b[i] <= 'Z')
b[i] += 32;
int t = strcmp(a, b);
if(t == 0) cout <<"=" << endl;
else if(t > 0) cout << ">" << endl;
else cout << "<" << endl;
return 0;
}