分析:
50张选票-->char xp[50][20];
3个候选人(姓名,票数)
struct person
{
char name[20];
int cnt;
};
typedef struct person stu;
void count(stu st[],int n,char tt[][20])
{
遍历50张选票
{
判断当前选票属于谁,相应的票数加1
{
遍历3个候选人
{
如果选票属于某人,该人票数加1
}
}
}
}
void count(stu st[],int n,char tt[][20])
{
int i,j;
for(i=0;i<50;i++) //tt[i]
for(j=0;j<3;j++)
if (strcmp(tt[i],st[j].name)==0) st[j].cnt++;
}
上一页
[1]
[2]
[3]
[4]
[5]
下一页