uva10851--String暴力

来源:互联网 发布:网络改写的小说 编辑:程序博客网 时间:2024/05/22 17:31

暴力很好写。。我还是太嫩了。。

//#define LOCAL#include <stdio.h>#include <string.h>#include <ctype.h> #include <stdlib.h> #define MAXN 1000010 + 10#define MAX 200 + 10int cmp(const void *_a, const void *_b);char word[MAXN][MAX];int n = 0, len = 0;int main(){#ifdef LOCALfreopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);#endifint 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);}


原创粉丝点击