Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int tc,i,total=0,num,c=0,r=0,s=0;
- char name;
- double per_c,per_r,per_s;
- scanf("%d",&tc);
- for(i=0;i<tc;i++){
- scanf("%d %c",&num,&name);
- total=total+num;
- if(name=='C'){
- c=c+num;
- }
- else if(name=='R'){
- r=r+num;
- }
- else if(name=='S'){
- s=s+num;
- }
- }
- per_c= ((c/double(total))*100);
- per_r=((r/double(total))*100);
- per_s=((s/double(total))*100);
- printf("Total: %d cobaias\n",total);
- printf("Total de coelhos: %d\n",c);
- printf("Total de ratos: %d\n",r);
- printf("Total de sapos: %d\n",s);
- printf("Percentual de coelhos: %0.2lf %%\n",per_c);
- printf("Percentual de ratos: %0.2lf %%\n",per_r);
- printf("Percentual de sapos: %0.2lf %%\n",per_s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement