有点技术含量的代码!来看看那里有错.嘿嘿.
#include "stdio.h"int main()
{
int grade;
int acount =0;
int bcount =0;
int ccount =0;
int dcount =0;
int fcount =0;
printf ("enter the letter grades.\n");
printf ("enter the EOF character to end input.\n" );
while ( (grade=getchar() ) !=EOF){
switch (grade){
case 'A' :
case 'a' :
++acount ;
break ;
case 'B' :
case 'b' :
++bcount ;
break ;
case 'C' :
case 'c' :
++ccount ;
break ;
case 'D' :
case 'd' :
++ccount ;
break ;
case 'F' :
case 'f' :
++ccount ;
break ;
case '\n':
case '\t':
case ' ':
break ;
default :
printf ("incorrect letter grade entered.");
printf ("enter a new grade.\n");
break ;
}
}
printf ("\n totals for each letter grade are:\n");
printf ("A: &d\n",acount);
printf ("B: &d\n",bcount);
printf ("C: &d\n",ccount);
printf ("D: &d\n",dcount);
printf ("F: &d\n",fcount);
getch();
}
测试的时候要不要自己的要求.whitch case default 语句