http://acm.hdu.edu.cn/showproblem.php?pid=2072
此题只需将句子中的字符串分开然后进行比较即刻。
#include <stdio.h>
#include <string.h>
char str[10005];
char a[100][25];
int main()
{
int count,i,j,f;
while(gets(str)&&strcmp(str,"#")!=0)
{
count=i=0;
while(str[i])
{
if(str[i]==' ')
{
i++;
continue;
}
f=j=0;
while(str[i]&&str[i]!=' ')
{
a[count][j++]=str[i++];
}
a[count][j]='\0';
for(int k=0;k<count;k++)
if(strcmp(a[count],a[k])==0)
{
f=1;
break;
}
if(f==0) count++;
}
printf("%d\n",count);
}
return 0;
}