AcWing 718. 实验
原题链接
困难
作者:
高小呆
,
2020-07-08 08:38:42
,
所有人可见
,
阅读 644
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n;
cin>>n;
double a[100],total=0.0;
double vc=0.0,vr=0.0,vf=0.0,c=0.0,r=0.0,f=0.0;
char b[100];
for(int i=0;i<n;i++)
{
cin>>a[i]>>b[i];
total=total+a[i];
if(b[i]=='C')
c=c+a[i];
else if(b[i]=='R')
r=r+a[i];
else if(b[i]=='F')
f=f+a[i];
}
printf("Total: %.0f animals\n",total);
printf("Total coneys: %.0f\n",c);
printf("Total rats: %.0f\n",r);
printf("Total frogs: %.0f\n",f);
vc=c/(c+r+f);
vr=r/(c+r+f);
vf=f/(c+r+f);
printf("Percentage of coneys: %.2f %\n",vc*100);
printf("Percentage of rats: %.2f %\n",vr*100);
printf("Percentage of frogs: %.2f %\n",vf*100);
}