/*-----------SGG-------------*/
/*-----------the c-----------*/
#include<stdio.h>
#include<string.h>
struct Name
/*结构体*/
{
char name[20];/*名字*/
int count;/*计数器*/
}pronse[3]={"张三",0,"李四",0,"王五",0};/*结构数组*/
int main(int argv, char argc[])
{
int i;
printf("get a name while -1 over");/*输入-1时结束*/
for(i=0;;i++)/*循环*/
{
scanf("%s",Name.name);
if(strcmp(Name.name,"张三"))pronse[1].count++;/*字符串比较*/
else if(strcmp(Name.name,"李四"))pronse[2].count++;
else if(strcmp(Name.name,"王五"))pronse[3].count++;
else if(strcmp(Name.name,"-1"))break;/*跳出*/
}
printf("张三: %d,李四: %d,王五: %d",pronse[1].count,pronse[2].count,pronse[3].count);/*输出*/
return 0;
}
/*应该就是这样了*/