Skip to main content

URI problem "1094 - Experiments " solution

#include<stdio.h>
int main()
{
    int n,x,i,a=0,b=0,c=0,t;
    double p,q,w;
    char m[2];
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d%s",&x,&m);
        if(m[0]=='C')
        {
            a=a+x;
        }
        if(m[0]=='R')
        {
            b=b+x;
        }
        if(m[0]=='S')
        {
            c=c+x;
        }
    }

    t=(a+b+c);

    p=((a/(t*1.00))*100.00);
    q=((b/(t*1.00))*100.00);
    w=((c/(t*1.00))*100.00);
    printf("Total: %d cobaias\n",t);
    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: %.2lf %%\n",p);
    printf("Percentual de ratos: %.2lf %%\n",q);
    printf("Percentual de sapos: %.2lf %%\n",w);
    return 0;
}

Comments

Popular posts from this blog

URI problem "1040- Average 3" solution

Here is the solution to URI problem ID: 1040 #include<stdio.h> #include<math.h> int main() {     double media, N1,N2,N3,N4,s,k;     scanf("%lf %lf %lf %lf",&N1,&N2,&N3,&N4);     media=((N1*2/10)+(N2*3/10)+(N3*4/10)+(N4*1/10));     printf("Media: %.1lf\n",media);     if(media>=7)     {         printf("Aluno aprovado.\n");     }     else if(media>=5.0&&media<=6.9)     {         printf("Aluno em exame.\n");         scanf("%lf",&s);         printf("Nota do exame: %.1lf\n",s);         k=(media+s)/2;         if(k>=5)         {       ...

URI problem "1065 - Even Between five Numbers " solution

#include<stdio.h> int main() {     int a,b,c,d,e;     int l,j,k,n,p,totale;     scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);     if(a%2==0)     {         l=1;     }     else     {         l=0;     }     if(b%2==0)     {         j=1;     }     else     {         j=0;     }     if(c%2==0)     {         k=1;     }     else     {         k=0;     }     if(d%2==0)     {         n=1;  ...