Problem with question 2144 URI [closed]

-7

Statement: link

The code I have:

{

    double direito,esquerdo,repeticao,e,d,m,c=0;
    while(1)
    {
        scanf("%lf %lf %lf",&esquerdo,&direito,&repeticao);
        if(esquerdo==0&&direito==0&&repeticao==0)
            break;
        d=direito*(1+(repeticao/30));
        e=esquerdo*(1+(repeticao/30));
        m=(d+e)/2;
        c+=m;
        if(m>=1&&m<13)
        {
            printf("Nao vai da nao\n");
        }
        else if(m>=13&&m<14)
        {
            printf("E 13\n");
        }
        else if(m>=14&&m<40)
        {
            printf("Bora, hora do show! BIIR! \n");
        }
        else if(m>=40&&m<=60)
        {
            printf("Ta saindo da jaula o monstro!\n");
        }
        else if(m>60)
        {
            printf("AQUI E BODYBUILDER!!\n");
        }
    }
    printf("\n\n");
        if(c>40)
        {
            printf("Aqui nois constroi fibra rapaz! Nao e agua com musculo!\n");
        }
    return 0;
}
    
asked by anonymous 01.11.2017 / 19:48

1 answer

1

The enunciado says:

  

At the end, if the average of all cases is greater than 40

You are adding up all the cases, but you are not dividing by the number of cases, so the average calculation is wrong.

Your problem is that you have to count how many times the code runs in while . Use a counter (let's call it cont ) for this, declared before while . Put cont++; on line after break; .

At the end, before if , make if (c != 0) c /= cont; .

In addition, see this string:

"Bora, hora do show! BIIR! \n"

That white space in the end will cause you problems.

    
02.11.2017 / 14:14