Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n,x,i,a=0,b=0,c=0,s,t,v;
- char ch;
- scanf("%d",&n);
- for(i=0;i<n;i++)
- {
- scanf("%d",&x);
- scanf("%c",&ch);
- //scanf("%d%c",&x,&ch);
- if(ch=='C')
- a+=x;
- else if(ch=='R')
- b+=x;
- else if(ch=='S')
- c+=x;
- }
- int total=a+b+c;
- float a1,b1,c1;
- a1=(a/total)*100;
- b1=(b/total)*100;
- c1=(c/total)*100;
- printf("Total: %d cobaias\n",total);
- printf("Total de coelhos: %d\n",a);
- printf("Total de ratos: %d\n",b);
- printf("Total de sapos: %d\n",c);
- printf("Percentual de coelhos: %.2f %\n",a1);
- printf("Percentual de ratos: %.2f %\n",b1);
- printf("Percentual de sapos: %.2f %\n",c1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement