题目链接:http://www.codeforces.com/problemset/problem/112/A
题意:忽略大小写,比较两个字符串字典序大小。
C++代码:
#include <cstdio> #include <cstring> int cmp(char *s, char *t) { while (*s) { if (*s <= 'Z') *s += 32; if (*t <= 'Z') *t += 32; if (*s < *t) return -1; else if (*s > *t) return 1; s ++; t ++; } return 0; } int main() { char *s = new char[110]; char *t = new char[110]; scanf("%s%s", s, t); printf("%d ", cmp(s, t)); }