AcWing 718. 实验
原题链接
简单
作者:
Jairus
,
2024-11-17 21:58:31
,
所有人可见
,
阅读 2
#include<iostream>
using namespace std;
int main()
{
int n=0,a=0,i=1,Total=0,c=0,r=0,f=0;
char m;
cin>>n;
while(i<=n)
{
cin>>a>>m;
Total+=a;
if(m=='C')
c+=a;
if(m=='R')
r+=a;
if(m=='F')
f+=a;
i++;
}
printf("Total: %d animals\nTotal coneys: %d\nTotal rats: %d\nTotal frogs: %d\nPercentage of coneys: %.2lf %%\nPercentage of rats: %.2lf %%\nPercentage of frogs: %.2lf %%",Total,c,r,f,c*100.0/Total,r*100.0/Total,f*100.0/Total);
return 0;
}