AcWing 718. 实验
原题链接
困难
作者:
冰语晨星
,
2020-03-10 18:08:44
,
所有人可见
,
阅读 524
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,coney=0,rat=0,frog=0;
cin>>n;
int num;
char ch;
for(int i=1;i<=n;i++)
{
cin>>num>>ch;
if(ch=='C') coney+=num;
else if(ch=='R') rat+=num;
else if(ch=='F') frog+=num;
}
printf("Total: %d animals\n",coney+rat+frog);
printf("Total coneys: %d\n",coney);
printf("Total rats: %d\n",rat);
printf("Total frogs: %d\n",frog);
printf("Percentage of coneys: %.2lf %%\n",100.0*coney/(coney+rat+frog));
printf("Percentage of rats: %.2lf %%\n",100.0*rat/(coney+rat+frog));
printf("Percentage of frogs: %.2lf %%\n",100.0*frog/(coney+rat+frog));
return 0;
}