include [HTML_REMOVED]
int main()
{
double Cp,Rp,Fp;
int i,N,cnt,sum=0,Csum=0,Rsum=0,Fsum=0;
char ch;
scanf(“%d”,&N);
for(i=1;i<=N;i++)
{
scanf(“%d %c”,&cnt,&ch);
sum+=cnt;
if(ch==’C’) Csum+=cnt;
else if(ch==’R’) Rsum+=cnt;
else Fsum+=cnt;
}
Cp=1.0Csum/sum;
Rp=1.0Rsum/sum;
Fp=1.0*Fsum/sum;
printf(“Total: %d animals\n”,sum);
printf(“Total coneys: %d \n”,Csum);
printf(“Total rats: %d \n”,Rsum);
printf(“Total frogs: %d \n”,Fsum);
printf("Percentage of coneys: %.2lf%%\n",Cp*100);
printf("Percentage of rats: %.2lf%%\n",Rp*100);
printf("Percentage of frogs: %.2lf%%\n",Fp*100);
return 0;
}
```
修改一下代码格式吧~
把代码放在```之间