AcWing 718. 实验
原题链接
简单
作者:
呆jio不
,
2024-11-12 21:12:05
,
所有人可见
,
阅读 2
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n,x;
double nums=0,c=0,r=0,f=0;
char a;
cin>>n;
while(n--!=0){
cin>>x>>a;
nums=nums+x;
if(a=='C') c=c+x;
else if(a=='R') r+=x;
else f+=x;
}
cout<<"Total: "<<nums<<" animals"<<endl;
cout<<"Total coneys: "<<c<<endl;
cout<<"Total rats: "<<r<<endl;
cout<<"Total frogs: "<<f<<endl;
printf("Percentage of coneys: %.2lf %%\n",c/nums*100);
printf("Percentage of rats: %.2lf %%\n",r/nums*100);
printf("Percentage of frogs: %.2lf %%\n",f/nums*100);
return 0;
}