AcWing 718. 实验
原题链接
简单
作者:
赵珂欣
,
2024-11-17 08:04:21
,
所有人可见
,
阅读 1
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int N;
cin >> N;
int x,x1 = 0,x2 = 0,x3 =0;
for (int i = 1;i <= N; i++)
{
int a;
char b;
cin >> a >> b;
x += a;
if (b == 'C') x1 += a;
else if (b == 'R') x2 += a;
else if (b == 'F') x3 += a;
}
cout << "Total: " << x << " animals" <<endl;
cout << "Total coneys: " << x1 << endl;
cout << "Total rats: " << x2 << endl;
cout << "Total frogs: " << x3 << endl;
printf("Percentage of coneys: %.2lf %%\n",(x1*1.0/x)*100);
printf("Percentage of rats: %.2lf %%\n",(x2*1.0/x)*100);
printf("Percentage of frogs: %.2lf %%\n",(x3*1.0/x)*100);
return 0;
}