AcWing 718. 实验
原题链接
简单
作者:
深街酒徒
,
2024-11-20 14:40:37
,
所有人可见
,
阅读 1
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
cin >> n;
int cnum = 0, rnum = 0, fnum = 0, num = 0;
for(int i = 0; i < n; i++)
{
int x;
char c;
cin >> x >> c;
if(c == 'C') cnum += x;
else if(c == 'R') rnum += x;
else if(c == 'F') fnum += x;
num += x;
}
printf("Total: %d animals\n", num);
printf("Total coneys: %d\n", cnum);
printf("Total rats: %d\n", rnum);
printf("Total frogs: %d\n", fnum);
printf("Percentage of coneys: %.2f %\n", cnum / (num * 1.0) * 100);
printf("Percentage of rats: %.2f %\n", rnum / (num * 1.0) * 100);
printf("Percentage of frogs: %.2f %\n", fnum / (num * 1.0) * 100);
return 0;
}