实验
作者:
什么意思O_o
,
2024-10-18 18:53:17
,
所有人可见
,
阅读 2
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
double N,A,sum=0,x=0,y=0,z=0;
char T;
cin>>N;
for(int i=1;i<=N;i++)
{
cin>>A>>T;
sum+=A;
if(T=='C') x+=A;
else if(T=='R')y+=A;
else z+=A;
}
cout<<"Total: "<<sum<<" animals"<<endl;
cout<<"Total coneys: "<<x<<endl;
cout<<"Total rats: "<<y<<endl;
cout<<"Total frogs: "<<z<<endl;
printf("Percentage of coneys: %.2lf %%\n",x/sum*100);
printf("Percentage of rats: %.2lf %%\n",y/sum*100);
printf("Percentage of frogs: %.2lf %%\n",z/sum*100);
return 0;
}