Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, amount, total=0, coelho=0, rato=0, sapo=0;
- double per_coelho, per_rato, per_sapo;
- char type;
- scanf("%d", &n);
- while(n--)
- {
- scanf("%d %c", &amount, &type);
- total=total+amount;
- if(type == 'C')
- {
- coelho=coelho+amount;
- }
- else if(type == 'R')
- {
- rato=rato+amount;
- }
- else if(type == 'S')
- {
- sapo=sapo+amount;
- }
- }
- printf("Total: %d cobaias\n", total);
- printf("Total de coelhos: %d\n", coelho);
- printf("Total de ratos: %d\n", rato);
- printf("Total de sapos: %d\n", sapo);
- per_coelho=(coelho*100)/total;
- per_rato=(rato*100)/total;
- per_sapo=(sapo*100)/total;
- printf("Percentual de coelhos: %.2lf %%\n", per_coelho);
- printf("Percentual de ratos: %.2lf %%\n", per_rato);
- printf("Percentual de sapos: %.2lf %%\n", per_sapo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement