AcWing 718. 实验——无超纲(正常版)
原题链接
困难
作者:
小钰爱吃鱼
,
2021-07-23 09:10:31
,
所有人可见
,
阅读 213
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
cin >> n;
int c = 0, r = 0, f = 0;
for (int i = 0; i < n; i ++ )
{
int a;
char t;
cin >> a >> t;
if (t == 'C') c += a;
if (t == 'R') r += a;
if (t == 'F') f += a;
}
int s = c + r + f;
printf("Total: %d animals\n", s);
printf("Total coneys: %d\n", c);
printf("Total rats: %d\n", r);
printf("Total frogs: %d\n", f);
printf("Percentage of coneys: %.2lf %%\n", (double)c / s * 100);
printf("Percentage of rats: %.2lf %%\n", (double)r / s * 100);
printf("Percentage of frogs: %.2lf %%\n", (double)f / s * 100);
return 0;
}