AcWing 718. 实验
原题链接
简单
作者:
MEthylene
,
2024-09-25 12:57:18
,
所有人可见
,
阅读 2
题目描述
样例
#include<stdio.h>
int main(){
int N;
int a[100]={0};
char b[100]={'C','F','R'};
int sumA=0,sumC=0,sumF=0,sumR=0;
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d %c",&a[i],&b[i]);
sumA+=a[i];
if(b[i]=='C')sumC+=a[i];
else if(b[i]=='F')sumF+=a[i];
else if(b[i]=='R')sumR+=a[i];
}
float PC=(sumC*1.0)/(sumA*1.0);
float PR=(sumR*1.0)/(sumA*1.0);
float PF=(sumF*1.0)/(sumA*1.0);
printf("Total: %d animals\n",sumA);
printf("Total coneys: %d\n",sumC);
printf("Total rats: %d\n",sumR);
printf("Total frogs: %d\n",sumF);
printf("Percentage of coneys: %.2f %\n",PC*100);
printf("Percentage of rats: %.2f %\n",PR*100);
printf("Percentage of frogs: %.2f %\n",PF*100);
return 0;
}