URI / BEE CROWD 1074 - Even or Odd Solution in C,C++,Python | URI - BEECROWD - BEE 1074 Solution in C,C++,Python
beecrowd | 1074
Even or Odd
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1Adapted by Neilor Tonin, URI Brazil
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 | ODD NEGATIVE |
URI / BEE CROWD 1074 - Even or Odd Solution in C,C++,Python | URI - BEECROWD - BEE 1074 Solution in C,C++,Python
Demonstration:
URI / BEE 1074 Solution in C :
URI / BEECROWD Online Judge 1074 Solve in C : |
#include <stdio.h>
int main()
{
int N,X,a;
scanf ("%d", &N);
for(a=1;a<=N;a++)
{
scanf ("%d",&X);
if(X==0)
printf("NULL\n");
else if(X<=0&&X%2==0)
printf ("EVEN NEGATIVE\n");
else if(X<=0&&X%2==-1)
printf ("ODD NEGATIVE\n");
else if(X>=0&&X%2==0)
printf ("EVEN POSITIVE\n");
else if(X>=0&&X%2==1)
printf ("ODD POSITIVE\n");
}
return 0;
}
0 Response to URI / BEE CROWD 1074 - Even or Odd Solution in C,C++,Python | URI - BEECROWD - BEE 1074 Solution in C,C++,Python
Post a Comment