统计候选人

#include 
#include 
void main()
{
	int s1=0,s2=0,s3=0,i;
	char str[100];
	char stu0[]={"stu0"};
	char stu1[]={"stu1"};
	char stu2[]={"stu2"};
	char stu3[]={"stu3"};
	printf("请输入投票人:");
	while(1)
	{

		scanf("%s",&str);
		if(strcmp(str,stu1)==0)
			s1++;
		if(strcmp(str,stu2)==0)
			s2++;
		if(strcmp(str,stu3)==0)
			s3++;
		if(strcmp(str,stu0)==0)
		{
			printf("stu1:%d\nstu2:%d\nstu3:%d\n",s1,s2,s3);
			break;
		}
	}
}

你可能感兴趣的:(C和C++,c语言)