#include<stdio.h>
int main()
{
int an, i, sumc = 0, sumr = 0, sums = 0, sum = 0, n;
double a, b, c;
char ch;
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d %c",&an,&ch);
if(ch == 'C')
{
sumc = sumc + an;
}
else if(ch == 'R')
{
sumr = sumr + an;
}
else if(ch == 'S')
{
sums = sums + an;
}
sum = sum + an;
}
a = ((float)sumc*100)/(float)sum;
b = ((float)sumr*100)/(float)sum;
c = ((float)sums*100)/(float)sum;
printf("Total: %d cobaias\n",sum);
printf("Total de coelhos: %d\n",sumc);
printf("Total de ratos: %d\n",sumr);
printf("Total de sapos: %d\n",sums);
printf("Percentual de coelhos: %0.2lf %c\n",a,37);
printf("Percentual de ratos: %0.2lf %c\n",b,37);
printf("Percentual de sapos: %0.2lf %c\n",c,37);
return 0;
}
int main()
{
int an, i, sumc = 0, sumr = 0, sums = 0, sum = 0, n;
double a, b, c;
char ch;
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d %c",&an,&ch);
if(ch == 'C')
{
sumc = sumc + an;
}
else if(ch == 'R')
{
sumr = sumr + an;
}
else if(ch == 'S')
{
sums = sums + an;
}
sum = sum + an;
}
a = ((float)sumc*100)/(float)sum;
b = ((float)sumr*100)/(float)sum;
c = ((float)sums*100)/(float)sum;
printf("Total: %d cobaias\n",sum);
printf("Total de coelhos: %d\n",sumc);
printf("Total de ratos: %d\n",sumr);
printf("Total de sapos: %d\n",sums);
printf("Percentual de coelhos: %0.2lf %c\n",a,37);
printf("Percentual de ratos: %0.2lf %c\n",b,37);
printf("Percentual de sapos: %0.2lf %c\n",c,37);
return 0;
}
Comments
Post a Comment