主要学习一下怎么利用sort对二维字符数组排序
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 const int maxn = 3e5 + 10; 7 char s[maxn][50]; 8 char *str[maxn]; 9 10 // 11 bool cmp(const char *s1, const char *s2) { 12 return strcmp(s1, s2) < 0; 13 } 14 15 int main(int argc, const char * argv[]) { 16 int cnt = 0, p = 0; 17 char c; 18 while ((c = getchar()) != EOF) { 19 //if (c == '#') break; 20 if ('A' <= c && c <= 'Z') { 21 c = c - 'A' + 'a'; 22 s[cnt][p++] = c; 23 } else if ('a' <= c && c <= 'z') { 24 s[cnt][p++] = c; 25 } else { 26 if (p != 0) { 27 s[cnt][p] = '