#include <stdio.h>
#include <stdlib.h>
#include<string.h>
typedef struct Vote//定义一个结构体
{
    char name[50];
    int votes;
} VOTE;
int main()
{
    char ch[20];
    int i,n,j;
    VOTE p[5]=
    {
        {"zhang",0},
        {"wang",0},
        {"zhao",0},
        {"liu",0},
        {"miao",0}
    };
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",ch);
        for(j=0; j<5; j++)
        {
            if(strcmp(ch, p[j].name)==0)
                p[j].votes++;
        }
    }
    for(j=0;j<5;j++)
    {
        printf("%s %d\n",p[j].name, p[j].votes);
    }
    return 0;
}选票统计(一)(结构体专题)C语言

相关文章:

  • 2021-06-02
  • 2022-01-13
  • 2022-02-13
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2021-06-17
  • 2022-01-21
  • 2021-10-01
  • 2021-07-07
相关资源
相似解决方案