注意:
(1)输字符时一定要有单引号
(2)百分号要写成%%
(3)整数涉及小数时要强制类型转换
(4)有百分号时注意要不要乘以100
include[HTML_REMOVED]
using namespace std;
int main( )
{
int n,i,a,c=0,r=0,f=0,s=0;
char t;
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
scanf(“%d %c”,&a,&t);
s=a+s;
if(t==’C’)
c=a+c;
else if(t==’F’)
f=a+f;
else if(t==’R’)
r=a+r;
}
printf(“Total: %d animals\n”,s);
printf(“Total coneys: %d\n”,c);
printf(“Total rats: %d\n”,r);
printf(“Total frogs: %d\n”,f);
printf(“Percentage of coneys: %.2f %%\n”,(double)c/s100);
printf(“Percentage of rats: %.2f %%\n”,(double)r/s100);
printf(“Percentage of frogs: %.2f %%\n”,(double)f/s*100);
return 0;
}