1.定义结构体类型,包括候选人名和选票两个成员,编程实现对候选人得票的统计。
1.Write a C program that implements the statistics of the candidate votes using the definition of structures including two members ( candidate name and vote count)
#include<stdio.h>
#include<string.h>
int main()
{
struct person
{
char name[7];
int count;
};
struct person leader[2]={
"Biden",0,"Trump",0};
int i,j;
char leadername[7];
for(i=0;i<5;i++)
{
scanf("%s",leadername);
for(j=0;j<2;j++)
if(strcmp(leadername,leader[j].name)==0)
leader[j].count++;
}
for(i=0;i<2;i++)