水题手速不都快 思维还是不是非常流畅 继续锻炼
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
struct Words
{
char s[205];
}words[5005];
int T;
int cmp(struct Words a, struct Words b)
{
int i;
for(i = 0; a.s[i]!='\0'&&b.s[i]!='\0'; i++)
if(a.s[i] < b.s[i] )return 1;
else if(a.s[i] > b.s[i] )return 0;
if(a.s[i] == '\0') return 1;
if(b.s[i] == '\0') return 0;
}
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif // LOCAL
char str[205];
int i, j;
while(gets(str)!=NULL)
{
if(str[0]=='\n')continue;
char s[205];
int len_str = strlen(str);
for(i = 0; i < len_str; i++)
{
int t = 0;
if(!isalpha(str[i]))continue;
while(isalpha(str[i]))s[t++] = tolower(str[i++]);
s[t] = '\0';
if(T == 0){strcpy(words[T++].s,s);continue;}
for(j = 0; j < T; j++)
if(strcmp(words[j].s,s) == 0)break;
if(j == T) strcpy(words[T++].s,s);
}
}
sort(words,words+T,cmp);
for(i = 0; i < T; i++)
puts(words[i].s);
return 0;
}