水题反映一个问题。。。。我很不认真。。。
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
double sum,sumc,c,s[14]={4.0,3.7,3.3,3.0,2.7,2.3,2.0,1.7,1.3,1.0,0.0};
string ch[14]={"A","A-","B+","B","B-","C+","C","C-","D","D-","F"},str;
int n;
while(cin>>n)
{
sum=0;
sumc=0;
for(int i=0;i<n;i++)
{
cin>>c>>str;
if(str=="P"||str=="N")
continue;
for(int j=0;j<14;j++)
{
if(str==ch[j])
{
sum+=(1.0*s[j]*c);
sumc+=c;
break;
}
}
}
sum=1.0*sum/sumc;
if(sumc==0) cout<<"0.00"<<endl;
else printf("%.2lf\n",sum);
}
}