Algorithm


Problem Name: beecrowd | 1074
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1074

Even or Odd

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value N. After, read these N values and print a message for each value saying if this value is odd, even, positive or negative. In case of zero (0), although the correct description would be "EVEN NULL", because by definition zero is even, your program must print only "NULL", without quotes.

Input

The first line of input is an integer N (N < 10000), that indicates the total number of test cases. Each case is a integer number X (-107 < X <107)..

Output

For each test case, print a corresponding message, according to the below example. All messages must be printed in uppercase letters and always will have one space between two words in the same line.

Input Sample Output Sample

4
-5
0
3
-4

ODD NEGATIVE
NULL
ODD POSITIVE
EVEN NEGATIVE

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main( ){

    int N, i, x;
    scanf("%d", &N);
    for( i = 1; i  < = N; i++){
        scanf("%d", &x);
        if(x == 0){
        printf("NULLn");
        } else if(x % 2 == 0) {
            if(x > 0){
                printf("EVEN POSITIVEn");
            } else {
                printf("EVEN NEGATIVEn");
            }
        } else {
            if(x > 0) {
                printf("ODD POSITIVEn");
            } else {
                printf("ODD NEGATIVEn");
            }
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 -5 0 3 -4

Output

x
+
cmd
ODD NEGATIVE NULL ODD POSITIVE EVEN NEGATIVE

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main()
{
    int n, x;

    cin >> n;

    for (int i = 0; i  <  n; ++i)
    {
        cin >> x;

        if(x == 0) {
            cout << "NULL" << endl;
        } else if(x % 2 == 0) {
            if(x > 0) {
                cout << "EVEN POSITIVE" << endl;
            } else {
                cout << "EVEN NEGATIVE" << endl;
            }
        } else {
            if(x > 0) {
                cout << "ODD POSITIVE" << endl;
            } else {
                cout << "ODD NEGATIVE" << endl;
            }

        }
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 -5 0 3 -4

Output

x
+
cmd
ODD NEGATIVE NULL ODD POSITIVE EVEN NEGATIVE

#3 Code Example with Java Programming

Code - Java Programming


import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        int N, i, x;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        for( i = 1; i  < = N; i++) {
            x = sc.nextInt();
            if(x == 0) {
                System.out.printf("NULLn");
            } else if(x % 2 == 0) {
                if(x > 0) {
                    System.out.printf("EVEN POSITIVEn");
                } else {
                    System.out.printf("EVEN NEGATIVEn");
                }
            
            } else {
                if(x > 0) {
                    System.out.printf("ODD POSITIVEn");
                } else {
                    System.out.printf("ODD NEGATIVEn");
                }
            }
    
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 -5 0 3 -4

Output

x
+
cmd
ODD NEGATIVE NULL ODD POSITIVE EVEN NEGATIVE

#4 Code Example with Python Programming

Code - Python Programming


l=[]
a=int(input())
for n in range(1,(a+1)):
    l.append(int(input()))
for n in l:
    if (n%2!=0)and (n0):
        print("ODD POSITIVE")
    if(n%2==0)and(n0):
        print("EVEN POSITIVE")
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 -5 0 3 -4

Output

x
+
cmd
ODD NEGATIVE NULL ODD POSITIVE EVEN NEGATIVE
Advertisements

Demonstration


Previous
#1073 Beecrowd Online Judge Solution 1073 Even Square - Solution in C, C++, Java, Python and C#
Next
#1075 Beecrowd Online Judge Solution 1075 Remaining 2 - Solution in C, C++, Java, Python and C#