AcWing 718. 实验
原题链接
简单
作者:
jaemin
,
2025-01-12 01:23:30
,
所有人可见
,
阅读 1
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,s,c=0,r=0,f=0;
cin>>n;
char a;
for(int i=0;i<n;i++)
{
cin>>s;
cin>>a;
if(a=='C')
c+=s;
else if(a=='R')
r+=s;
else
f+=s;
}
printf("Total: %d animals\n",c+r+f);
printf("Total coneys: %d\n",c);
printf("Total rats: %d\n",r);
printf("Total frogs: %d\n",f);
printf("Percentage of coneys: %.2f %\n",(float)c/(c+r+f)*100);
printf("Percentage of rats: %.2f %\n",(float)r/(c+r+f)*100);
printf("Percentage of frogs: %.2f %\n",(float)f/(c+r+f)*100);
}