XJOI 计算每个用户的 AC 率的方法是将所有提交结果为AC的的数量除以提交的总数。
现给定某用户的提交记录:‘AAAAWAAACRTWWA’
字母“A”表示Accepted。 字母“W”表示Wrong Answer。 字母“C”表示Compile Error。 字母“T”表示超过Time Limit Exceeded。 字母“R”表示Runtime Error。
现在根据某位用户的提交记录,计算他的AC率('AC’表示当提交结果为’A’时)、WA率('WA’表示当提交结果为’W’时)和CE率(‘CE’表示当提交结果是’C’)。
#include<bits/stdc++.h>
using namespace std;
int main()
{
char ch;
int a=0,c=0,w=0,tot=0;
while(cin>>ch,ch!=‘?’)
{
if(ch==‘A’)a++;
if(ch==‘C’)c++;
if(ch==‘W’)w++;
tot++;
}
cout<<fixed<<setprecision(2)<<double(a)/tot<<endl;
cout<<fixed<<setprecision(2)<<double(w)/tot<<endl;
cout<<fixed<<setprecision(2)<<double(c)/tot<<endl;
return 0;
}