噌噌上涨还是蹭蹭上涨:高人请进呀~~~~
这是一个C语言程序题,请给出程序谢谢!
#include <stdio.h>
#include <string.h>
#define CHARLEN 50
typedef struct _VOTEINFO{
char nVoteNum[10];
char sCName[CHARLEN];
int nVoteTime;
}VOTEINFO,*PVOTEINFO;
int main()
{
int i,j;
VOTEINFO votes[5];
char ccode[10];
printf("Input Votes' Info by order:\n");
for(i=0;i<5;i++)
{
printf("Please Enter the [ %d ]'s candidate Code:\n",i+1);
scanf("%s",&votes[i].nVoteNum);
printf("please Enter the [ %d ]'s candidate name:\n",i+1);
scanf("%s",votes[i].sCName );
votes[i].nVoteTime = 0;
}
printf(" Display the candidates' Infomations:\n");
printf("----candidateName----candidateNum----\n");
for(i=0;i<5;i++)
{
printf("\t%s\t\t%s\t\n",votes[i].sCName,votes[i].nVoteNum);
}
printf("Now, Vote Begin...\n");
for(i=0;i<10;i++)
{
printf("[%d] voter choose the candidate code :\n",i+1);
scanf("%s",ccode);
for(j=0;j<5;j++)
{
if (strcmp(votes[j].nVoteNum,ccode)==0)
{
votes[j].nVoteTime++;
break;
}
}
if (j == 5)
printf("Illegal Votes!!\n");
}
printf("Now,Display the Vote Result:\n");
printf("----candidateName----candidateNum----NumOfVote(s)\n");
for(i=0;i<5;i++)
{
printf("\t%s\t\t%s\t\t%d\t\n",votes[i].sCName,votes[i].nVoteNum,votes[i].nVoteTime );
}
return 0;
}
没有判断重复代号,不好意思了