TEMA

Wrong answer (20%)

Richard Lazarte preguntado 3 years ago

I don't know why gives me an error, I introduces the examples in the problem and prints the same.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,i,a,b;
    cin>>n;
    i=1;
    a=0;
    b=0;
    if (n<10000)
    {
        while (i<=n)
        {
            cin>>x;
            if (x%2==0)
            {
                if (x>0)
                {
                    cout<<"EVEN POSITIVE"<<endl;
                }
                if (x<0)
                {
                    cout<<"EVEN NEGATIVE"<<endl;
                }
            }
            else
            {
                if (x>0)
                {
                    cout<<"ODD POSITVE"<<endl;
                }
                if (x<0)
                {
                    cout<<"ODD NEGATIVE"<<endl;
                }
            }
            if (x==0)
            {
                cout<<"NULL"<<endl;
            }
            i=i+1;
        }
    }
}

Recuerda no enviar soluciones. Tu mensaje puede ser revisado por nuestros moderadores.

  • Antonio Augusto Menezes de Oliveira respondido 3 years ago

    Because you have to test fisrt the x==0, and the other code's part into the else. For to test the others situations you should use the &&. This it would enable you to use only if, without else, except the else's in the first part. Also is unnecessary to test n<10000. Sorry for my english. I hope I have helped you.

  • Leonardo Felipe Pereira Pinto respondido 3 years ago

    Quando vc pega o resto de 0 dividido por 2 também dá zero. Então no primeiro if tem que ser. if (x%2 == 0 && x!=0)