AcWing 718. 实验
原题链接
困难
作者:
我要出去乱说
,
2021-01-17 14:17:24
,
所有人可见
,
阅读 273
#include <cstdio>
int main() {
int c_num = 0, r_num = 0, f_num = 0, total = 0;
int n;
scanf("%d", &n);
while (n -- ) {
int t;
char op[2];
scanf("%d%s", &t, op);
total += t;
if (op[0] == 'C') c_num += t;
else if (op[0] == 'R') r_num += t;
else f_num += t;
}
printf("Total: %.0lf animals\n", total * 1.0);
printf("Total coneys: %.0lf\nTotal rats: %.0lf\nTotal frogs: %.0lf\n", c_num * 1.0, r_num * 1.0, f_num * 1.0);
printf("Percentage of coneys: %.2lf \%\nPercentage of rats: %.2lf %%\nPercentage of frogs: %.2lf \%", c_num * 1.0 / total * 100, r_num * 1.0 / total * 100, f_num * 1.0 / total * 100);
return 0;
}