Problem with URI issue 2144

Asked

Viewed 141 times

-7

Enunciation: https://www.urionlinejudge.com.br/judge/pt/problems/view/2144

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;
}
  • Try to format your question in a more user-friendly way, such as the final status of your question: https://answall.com/q/251296/64969

  • Your code has nothing to do with the statement here: https://www.urionlinejudge.com.br/judge/pt/problems/view/2114 - Are you sure the correct number is 2114?

  • pardon, right question 2144

  • Can you post the full code? That break; makes me suggest that there might be something wrong with your loop.

  • You should share the c for something before the if at the end. To know what it would be like, you would have to see your whole code.

  • ready now the code is complete

  • It is not yet complete because the #include <stdio.h> int main(int argc, char**argv). But that was enough to produce a response.

Show 2 more comments

1 answer

1

The enunciation says:

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

You’re adding up all the cases, but you’re 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 on while. Use an accountant (let’s call it cont) for this purpose, declared before the while. Put a cont++; on the line after the break;.

In the end, before the if, do if (c != 0) c /= cont;.

Also, see this string:

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

That white space at the end will cause you trouble.

  • 1

    "That white space at the end can cause you problems." == > URI considers presentation error, Presentation error

  • 1

    @Jeffersonquesado Thank you very much for the information. I exchanged "can" for "go".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.