题目描述
题目中等,注意输出格式即可。
样例
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, a, s = 0;
double c = 0, r = 0, f = 0 ;
char t;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a >> t;
s += a;
if(t == 'C') c += a;
if(t == 'R') r += a;
if(t == 'F') f += a;
}
cout << "Total: " << s << " animals" << endl;
cout << "Total coneys: " << c << endl;
cout << "Total rats: " << r << endl;
cout << "Total frogs: " << f << endl;
cout << "Percentage of coneys: " << fixed << setprecision(2) << c * 100.0 / s << " %" << endl;
cout << "Percentage of rats: " << fixed << setprecision(2) << r * 100.0 / s << " %" << endl;
cout << "Percentage of frogs: " << fixed << setprecision(2) << f * 100.0 / s << " %" ;
return 0;
}