#include<stdio.h> #define SC scanf #define PR printf struct person { char name[20]; int count,code; float pec; }leader[20]; main() { int n,i; char c; void scan(struct person leader[],int n); void arith(struct person leader[],int n); void diagram(struct person leader[],int n); PR("The Course Is Made By Tongxin'Yiban Yan Yonggang.
Now Press Enter For Running The Course.
"); while(getchar()!='
'); while(1) {PR("
Input the number of candidates:"); do {SC("%d",&n); if(n>1&&n<=20)break; else if(n<=1)PR("The candidates'number is too small.Input again!"); else if(n>20)PR("The candidates'number is too large.Input again!"); }while(1); scan(leader,n); arith(leader,n); PR("
Now press any key for looking diagram."); getchar(); getchar(); diagram(leader,n); for(;;) { PR("
Continued(Y/N)?"); c=getchar(); getchar(); if(c=='Y'c=='y'c=='N'c=='n')break; } if(c=='y'c=='Y') else break; } } void scan(struct person leader[],int n) { int i,j,k,flag=1; static char a1[67][35]; char c; for(j=0;j<34;j++) for(i=0;i<67;i+=3) a1[i][j]=196; for(i=0;i<67;i++)
for(i=3;i<=3*n;i+=3)
a1[0][0]=218;a1[0][20]=194;a1[0][34]=191;a1[3*n+3][0]=192;a1[3*n+3][20]=193;a1[3*n+3][34]=190; while(flag) { PR("
Input the candidates name and code.If only input name,system will
give code one by one.
"); PR("If only input name,press S,else press others."); getchar(); c=getchar(); if(c=='s'c=='S') { PR("Input name:"); for(i=0;i<n;i++) } else {PR("Input name and code:"); for(i=0;i<n;i++)SC("%s%d",&leader[i].name,&leader[i].code);} PR("This is candidates'name and code:"); a1[1][9]='N';a1[1][10]='a';a1[1][11]='m';a1[1][12]='e'; a1[1][27]='C';a1[1][28]='o';a1[1][29]='d';a1[1][30]='e'; for(i=0;i<2;i++) {PR("
"); for(j=0;j<35;j++)PR("%c",a1[i][j]);} for(i=0;i<4;i++) for(i=3;i<=3*n+3;i+=3) for(j=0;leader[i/3-1].name[j]!=' ';j++)a1[i+1][j+1]=leader[i/3-1].name[j]; for(i=3;i<=3*n+3;i++) {PR("
"); if((i+2)%3!=0i<3)for(j=0;j<35;j++)PR("%c",a1[i][j]); else PR("%c%-19s%c%10d %c",a1[i][0],leader[i/3-1].name,a1[i][20],leader[i/3-1].code,a1[i][34]); } for(;;) { PR("
Right(Y/N)?"); getchar(); c=getchar(); if(c=='Y'c=='y') else if(c=='N'c=='n')break; } } } void arith(struct person leader[],int n) { int i,j,k,s=0,x,flag=1; float m,p; static char c,a1[67][55]; for(j=0;j<55;j++) for(i=0;i<67;i+=3) a1[i][j]=196; for(i=0;i<67;i++)
for(i=3;i<=3*n;i+=3)
a1[0][0]=218;a1[0][20]=194;a1[0][34]=194;a1[0][44]=194;a1[0][54]=191;a1[3*n+3][0]=192;a1[3*n+3][20]=193;a1[3*n+3][34]=193;a1[3*n+3][44]=193;a1[3*n+3][54]=190; while(flag) { PR("Input the total of vote(an integar):"); SC("%d",&k); PR("Input the needed revery(a persontage):"); SC("%f%c",&m,&c); PR("Now beginning vote:
"); for(;;)