编程还有正确答案呀,俺这属于非正确,嘿嘿
#include <stdio.h>
int main(void)
{
int c, sum = 0, i = 0, j = 0;
while ((c = getchar()) != EOF) {
switch (c) {
case 'A': sum += 4; i++; break;
case 'B': sum += 3; i++; break;
case 'C': sum += 2; i++; break;
case 'D': sum += 1; i++; break;
case 'F': sum += 0; i++; break;
case ' ': break;
case '\n':
if (i && 0 == j)
printf("%.2f\n", (double)sum / i);
sum = i = j = 0;
break;
default:
++j;
if (1 == j)
printf("unknown\n");
break;
}
}
return 0;
}