Advertisement
Guest User

talha

a guest
Oct 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,x,i,a=0,b=0,c=0,s,t,v;
  5.     char ch;
  6.     scanf("%d",&n);
  7.     for(i=0;i<n;i++)
  8.     {
  9.         scanf("%d",&x);
  10.         scanf("%c",&ch);
  11.         //scanf("%d%c",&x,&ch);
  12.         if(ch=='C')
  13.          a+=x;
  14.         else if(ch=='R')
  15.             b+=x;
  16.         else if(ch=='S')
  17.             c+=x;
  18.  
  19.     }
  20. int total=a+b+c;
  21. float a1,b1,c1;
  22. a1=(a/total)*100;
  23. b1=(b/total)*100;
  24. c1=(c/total)*100;
  25. printf("Total: %d cobaias\n",total);
  26. printf("Total de coelhos: %d\n",a);
  27. printf("Total de ratos: %d\n",b);
  28. printf("Total de sapos: %d\n",c);
  29. printf("Percentual de coelhos: %.2f %\n",a1);
  30. printf("Percentual de ratos: %.2f %\n",b1);
  31. printf("Percentual de sapos: %.2f %\n",c1);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement