mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
2b2ae8c977
2300-2399
51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
#include<stdio.h>
|
|
#include<string.h>
|
|
int main()
|
|
{
|
|
char s[1000];
|
|
int i,num,flag;
|
|
double t;
|
|
while(gets(s))
|
|
{
|
|
t=0;
|
|
num=0;
|
|
i=0;
|
|
flag=0;
|
|
while(s[i])
|
|
{
|
|
switch(s[i++])
|
|
{
|
|
case 'A':
|
|
t+=4.0;
|
|
num++;
|
|
continue;
|
|
case 'B':
|
|
t+=3.0;
|
|
num++;
|
|
continue;
|
|
case 'C':
|
|
t+=2.0;
|
|
num++;
|
|
continue;
|
|
case 'D':
|
|
t+=1.0;
|
|
num++;
|
|
continue;
|
|
case 'F':
|
|
num++;
|
|
continue;
|
|
case ' ':
|
|
continue;
|
|
default:
|
|
flag=1;
|
|
break;
|
|
}
|
|
}
|
|
if(flag==1)
|
|
printf("Unknown letter grade in input\n");
|
|
else
|
|
printf("%.2lf\n",t/num);
|
|
}
|
|
return 0;
|
|
}
|