/* 投票情况统计 */ #include<stdio.h> int main(void) { int count[9]; int i,response; for(i=1;i<=8;i++) count[i]=0; for(i=1;i<=1000;i++){ printf("input your response:"); scanf_s("%d",&response); if(response<1||response>8) printf("this is a bad response:%d ",response); else count[response]++; } printf("result: "); for(i=1;i<=8;i++) printf("%4d%4d ",i,count[i]); return 0; }