需要强制转换
#include<cstdio>
int main(){
int n,num;
char t;
int c=0,r=0,f=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %c",&num,&t);
if(t=='C')c+=num;
else if(t=='R')r+=num;
else if(t=='F')f+=num;
}
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: %.2lf %%\n",double(c)/double(c+r+f)*100);
printf("Percentage of rats: %.2lf %%\n",double(r)/double(c+r+f)*100);
printf("Percentage of frogs: %.2lf %%\n",double(f)/double(c+r+f)*100);
return 0;
}