Introduction - If you have any usage issues, please Google them yourself
#include <iostream>
using namespace std
struct Person//声明结构体类型Person;
{
char name[20]
int count
}
int main()
{
Person leader[3]={"aaa",0,"bbb",0,"ccc",0}
//定义Person类型的数组,内容为当前候选人的姓名及得票数;
char leader_name[20] //leader_name为投票人所选的人姓名;
int i,j
for(i=0 i<10 i++)
{
cin>>leader_name //先后输入十张票上所选的人的姓名;
for(j=0 j<3 j++)
{
if(strcmp(leader_name,leader[j].name)==0)
leader[j].count++ //所选人与候选人的姓名相同,则该候选人的票数加1;
}
}
cout<<endl
double round
for(i=0 i<3 i++)
{
round=leader[i].count/10
cout<<leader[i].name<<":"<<"得票数:"<<leader[i].count<<"得票率:"<<round<<endl
}
return 0
}