解题思路:
先识别单词,再统计
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
#define MAX 1000
int main()
{
char str[MAX],temp[MAX];
char count[MAX][MAX];
int i,k,t,flag;
gets(str);
k=0;
for(i=0;i<strlen(str);i++)
{ int j=0;
if((str[i]!=' ') && str[i])
{
while((str[i]!=' ') && str[i])
{
temp[j]=str[i];
j++;
i++;
}
temp[j]='\0';
}
flag=0;
for(t=0;t<k;t++)
{
if(strcmp(count[t],temp) == 0)
{
flag=1;
}
}
if(flag == 0)//未统计
{
strcpy(count[k],temp);
k++;
}
}
printf("%d\n",k);
return 0;
}
0.0分
0 人评分