AcWing 718. 未使用数组
原题链接
简单
作者:
Winslow
,
2021-02-16 19:20:48
,
所有人可见
,
阅读 265
#include<iostream>
using namespace std;
int main()
{
int a;
int tc=0;
int tr=0;
int tf=0;
cin>>a;
for(int i=1;i<=a;i++)
{
int n=0;
char tab;
cin>>n>>tab;
if(tab=='C')tc+=n;
if(tab=='R')tr+=n;
if(tab=='F')tf+=n;
}
printf("Total: %d animals\n",tc+tr+tf);
printf("Total coneys: %d\n",tc);
printf("Total rats: %d\n",tr);
printf("Total frogs: %d\n",tf);
printf("Percentage of coneys: %.2lf %\n",1.00*tc/(tc+tr+tf)*100);
printf("Percentage of rats: %.2lf %\n",1.00*tr/(tc+tr+tf)*100);
printf("Percentage of frogs: %.2lf %\n",1.00*tf/(tc+tr+tf)*100);
return 0;
}