某单位进行选举,有5位候选人:李宁、王新、赵广、陈奇、六六。编写一个统计每人得票数的程序。要求每一个人的信息使用一个结构体表示,5个人的信息使用结构体数组。
#include<stdio.h>
int main()
{
struct
{
char name[10];
int num;
int count;
}man[5] = { {"李宁",1,0},{"王新",2,0},{"赵广",3,0},{"陈奇",4,0},{"六六",5,0} };
int i, n, flag = 0;
printf("Input the number(1-5):");
for (i = 1; i > 0; i++)
{
scanf_s("%d", &n);
switch (n)
{
case 1:man[0].count++; break;
case 2:man[1].count++; break;
case 3:man[2].count++; break;
case 4:man[3].count++; break;
case 5:man[4].count++; break;
default:flag = 1;
}
if (flag)
break;
}
printf("name\tno.\tcount\n");
for (i = 0; i < 5; i++)
printf("%s\t%d\t%d\n", man[i].name, man[i].num, man[i].count);
}
为什么我怎么输入运行结果都是0