原题在这里。代码写的比较乱
#include <cstdio>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
using namespace std;
const int maxn=5005,maxl=205;
int tot=0;
char word[maxn][maxl],now[maxl];
bool find(void)
{
for (int i=0; i<tot; i++)
if (!strcmp(now,word[i]))
return true;
return false;
}
int cmp(const void *a,const void *b)
{
return strcmp((char*)a,(char*)b);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("10815.in","r",stdin);
freopen("10815.out","w",stdout);
#endif
for (;;)
{
do
{
*now=getchar();
}
while (!isalpha(*now)&&*now!=EOF);
now[1]=0;
if (scanf("%[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]",now+1)==EOF)
break;
for (int i=0; now[i]; i++)
now[i]=tolower(now[i]);
if (!find())
memcpy(word[tot++],now,sizeof(now));
}
qsort(word,tot,sizeof(word[0]),cmp);
for (int i=0; i<tot; i++)
printf("%s\n",word[i]);
fclose(stdin);
fclose(stdout);
return 0;
}