#define Local
#include <stdio.h>
#include<stdlib.h>
#include <string.h>
char Dict[50000][250];
void SearchInsertDict (char word[], int *len_dict)
{
int i = 0, j = 0, flag = 1;
for (i = 0; i < *len_dict; i++)
{
if (0 == strcmp(word, Dict[i]))//==0字典里存在这个单词
{
flag = 0;
break;
}
}
if (flag)//不存在
{
strcpy(Dict[*len_dict], word);
(*len_dict)++;
}
}
void Strlwr(char s[])
{
for (int i = 0; i < strlen(s); i++)
if (s[i] >= 'A' && s[i] <= 'Z')
s[i] = s[i] + 32;
}
int cmp(const void *a, const void *b)
{
return strcmp((char *)a, (char *)b);
}
int main()
{
#ifdef Local
freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
#endif
int i = 0, j = 0, k = 0, len_dict = 0;
char sen[250], word[250];
while (gets(sen) != NULL)
{
Strlwr(sen);
for (i = 0; i < strlen(sen); i++)
{
int flag = 0;
memset(word, '\0', sizeof(word));
for (j = 0; sen[i] >= 'a' && sen[i] <= 'z'; i++, j++)
{
word[j] = sen[i];
flag = 1;
}
if (flag)
{
word[j] = '\0';
SearchInsertDict(word, &len_dict);
}
}
}
qsort(Dict, len_dict, sizeof(Dict[0]), cmp);
for (i = 0; i < len_dict; i++)
puts(Dict[i]);
}
uva - 10815 - Andy's First Dictionary
最新推荐文章于 2021-01-28 11:52:21 发布
