求高人:如果想程序当输入“ctrl+z”时才结束,怎样改编呢?(请见第9楼程序)有木有人会啊?
请见第9楼程序/*输入学生成绩,统计总人数和各个等级的人数*/
#include<stdio.h>
main()
{
int score,a,total=0,errtotal=0;
int acount=0,bcount=0,ccount=0,dcount=0,ecount=0;
printf("Please enter scores:\n");
while (score!=EOF)
{
scanf("%d",&score);
a=score%10;
if (score>=0)
{
switch(a)
{
case 10:
case 9:
{
++acount;
++total;
break;
}
case 8:
{
++bcount;
++total;
break;
}
case 7:
{
++ccount;
++total;
break;
}
case 6:
{
++dcount;
++total;
break;
}
default:
{
++ecount;
++total;
break;
}
}
}
else
{
printf("Sorry.You have input a wrong score.\n");
++errtotal;
}
}
printf("\n有效输入次数为:%d,无效输入次数为:%d\n",total,errtotal);
printf("总人数为:%d,成绩分布如下:\n");
printf("A级\tB级\tC级\tD级\tE级\n");
printf("%d人\t%d人\t%d人\t%d人\t%d人\n",acount,bcount,ccount,dcount,ecount);
}
[ 本帖最后由 huhao3225 于 2011-11-13 09:42 编辑 ]