AcWing 718. 实验
原题链接
困难
作者:
浙江星辰
,
2020-10-11 10:22:35
,
所有人可见
,
阅读 426
#include<iostream>
using namespace std;
int main(){
int nr=0,nc=0,nf=0,n,x;
char name;
cin>>n;
for(int i=1;i<=n;i++){
cin>>x>>name;
if(name=='R') nr=nr+x;
if(name=='F') nf=nf+x;
if(name=='C') nc=nc+x;
}
int s=nr+nc+nf;
printf("Total: %d animals\n",nr+nf+nc);
printf("Total coneys: %d\n",nc);
printf("Total rats: %d\n",nr);
printf("Total frogs: %d\n",nf);
printf("Percentage of coneys: %.2lf %\n",(double)nc*100/(double)s);
printf("Percentage of rats: %.2lf %\n",(double)nr*100/(double)s);
printf("Percentage of frogs: %.2lf %\n",(double)nf*100/(double)s);
return 0;
}