AcWing 718. 实验
原题链接
困难
作者:
古娜拉黑暗之神
,
2021-02-06 22:52:28
,
所有人可见
,
阅读 257
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n;
cin >> n;
int num,ani,num_c = 0,num_r = 0,num_f = 0;
while(true){
if(n == 0){
break;
}
scanf("%d %c",&num,&ani);
if(ani == 'C'){
num_c = num_c + num;
}else if(ani == 'R'){
num_r = num_r + num;
}else if(ani == 'F'){
num_f = num_f + num;
}
n--;
}
int numall = num_r+num_c+num_f;
printf("Total: %d animals\n",numall);
printf("Total coneys: %d\n",num_c);
printf("Total rats: %d\n",num_r);
printf("Total frogs: %d\n",num_f);
printf("Percentage of coneys: %.2f %\n",((float)num_c/numall) *100);
printf("Percentage of rats: %.2f %\n",((float)num_r/numall) * 100);
printf("Percentage of frogs: %.2f %\n",((float)num_f/numall) * 100);
return 0;
}