TOPIC
wrong answer 20%
PedroHenriqueCarvalho asked 2 years ago
O meu código está dando wrong answer 20% só não sei onde está o erro. alguem poderia me ajudar por favor
#include <stdio.h>
int main() {
int n,i,quant=0,total=0,totalC=0,totalR=0,totalS=0;
char tipo;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d""%c",&quant,&tipo);
if((quant>=1)&&(quant<=15)){
if(tipo=='c'){
totalC=totalC+quant;
}
else if(tipo=='r'){
totalR=totalR+quant;
}
else if(tipo=='s'){
totalS=totalS+quant;
}}
}
total=totalC+totalR+totalS;
printf("Total: %d cobaias\n",total);
printf("Total de coelhos: %d\n",totalC);
printf("Total de ratos: %d\n",totalR);
printf("Total de sapos: %d\n",totalS);
printf("Percentual de coelhos: %.2f %\n", (float)totalC * 100.0 / total);
printf("Percentual de ratos: %.2f %\n", (float)totalR * 100.0 / total);
printf("Percentual de sapos: %.2f %\n", (float)totalS * 100.0 / total);
return 0;
}
This topic has not been answered yet. Be the first!