大体就这样吧:
struct person
{
char name[20];
int score;
};
struct person a[n]={{"x",0},{"j",0},{"l",0},{"z",0}......};//n竞选的人数
int main()
{
int i,j;
char name[20];
for(i=0;i<
m;i++)//m票数
{printf("input a name:");
gets(name);
for(j=0;j<n;j++)
if(strcmp(name,a[j].name)==0)
{
a[j].score++;
break;
}
}
printf("\n");
for(i=0;i<n;i++)
printf("%5s:%d\n",a[i].name,a[i].score);
return 0;
}