文章目录
- AcWing 768. 忽略大小写比较字符串大小
- AC代码
AcWing 768. 忽略大小写比较字符串大小
本博客给出本题截图:
AC代码
代码:
#include <cstdio> #include <cstring> int main() { char a[100], b[100]; fgets(a, 100, stdin); fgets(b, 100, stdin); 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) puts("="); else if (t < 0) puts("<"); else puts(">"); return 0; }