暴力很好写。。我还是太嫩了。。
//#define LOCAL #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #define MAXN 1000010 + 10 #define MAX 200 + 10 int cmp(const void *_a, const void *_b); char word[MAXN][MAX]; int n = 0, len = 0; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif int i; char temp; while(1) { // 数据输入 if((temp = getchar()) == EOF) break; if(isalpha(temp)) word[n][len++] = tolower(temp); else if(isalpha(word[n][0])) { word[n++][len] = '\0'; len = 0; } } qsort(word, n, sizeof(word[0]), cmp); for(i = 0; i < n; i++) { if(strcmp(word[i], word[i + 1])) printf("%s\n", word[i]); } return 0; } int cmp(const void *_a, const void *_b) { char *a = (char *) _a; char *b = (char *) _b; return strcmp(a, b); }