题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<iostream>
using namespace std;
int main()
{
int n,a,c=0,r=0,f=0,sum=0;
char t;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a>>t;
if(t=='C') c+=a;
if(t=='R') r+=a;
if(t=='F') f+=a;
sum+=a;
}
printf("Total: %d animals\n",sum) ;
printf("Total coneys: %d\n",c) ;
printf("Total rats: %d\n",r);
printf("Total frogs: %d\n",f);
printf("Percentage of coneys: %0.2lf %\n",(double)(c*100)/sum);
printf("Percentage of rats: %0.2lf %\n",(double)(r*100)/sum);
printf("Percentage of frogs: %0.2lf %\n",(double)(f*100)/sum);
return 0;
}