#include<iostream>
using namespace std;
struct task
{
char name[10];//候选人名
int count; //得到的选票数
}cand[2]={{"liting",0},{"haier",0}};
int main()
{
int i,j;
char string[7];
printf("Please input some names:");
for(i=0;i<7;i++)
{
scanf("%s",string);
for(j=0;j<2;j++){
if(strcmp(cand[j].name,string)==0)
cand[j].count++;
}
}
printf("第一位候选人%s的票数是:%d\n第二位候选人%-6s的票数是:%d\n",cand[0].name,cand[0].count,cand[1].name,cand[1].count);
system("pause");
return(0);
}
using namespace std;
struct task
{
char name[10];//候选人名
int count; //得到的选票数
}cand[2]={{"liting",0},{"haier",0}};
int main()
{
int i,j;
char string[7];
printf("Please input some names:");
for(i=0;i<7;i++)
{
scanf("%s",string);
for(j=0;j<2;j++){
if(strcmp(cand[j].name,string)==0)
cand[j].count++;
}
}
printf("第一位候选人%s的票数是:%d\n第二位候选人%-6s的票数是:%d\n",cand[0].name,cand[0].count,cand[1].name,cand[1].count);
system("pause");
return(0);
}