quarta-feira, 24 de outubro de 2018

URI PROBLEMA 1074 - Par ou Ímpar SOLUÇÃO EM PYTHON


URI Online Judge | 1074


Par ou Ímpar



Adaptado por Neilor Tonin, URI  Brasil

Timelimit: 1




Leia um valor inteiro N. Este valor será a quantidade de valores que serão lidos em seguida. Para cada valor lido, mostre uma mensagem em inglês dizendo se este valor lido é par (EVEN), ímpar (ODD), positivo (POSITIVE) ou negativo (NEGATIVE). No caso do valor ser igual a zero (0), embora a descrição correta seja (EVEN NULL), pois por definição zero é par, seu programa deverá imprimir apenas NULL.



Entrada




A primeira linha da entrada contém um valor inteiro N(< 10000) que indica o número de casos de teste. Cada caso de teste a seguir é um valor inteiro (-107 < X <107).



Saída




Para cada caso, imprima uma mensagem correspondente, de acordo com o exemplo abaixo. Todas as letras deverão ser maiúsculas e sempre deverá haver um espaço entre duas palavras impressas na mesma linha.








URI Online Judge | 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 oddevenpositive 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 (< 10000), that indicates the total number of test cases. Each case is a integer number (-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.



n = int(input())
x =['']
for i in range(1,n + 1):
    x.append(int(input()))
   
for i in range(1,n + 1):
    if x[i] == 0:
        print('NULL')
       
    if x[i] > 0:
        if x[i] % 2 == 0:
            print('EVEN POSITIVE')
        else:
            print('ODD POSITIVE')
           
    if x[i] < 0:
        if x[i] % 2 == 0:
            print('EVEN NEGATIVE')
        else:
            print('ODD NEGATIVE')

Nenhum comentário:

Postar um comentário

URI PROBLEMA 1133 - Resto da Divisão SOLUÇÃO EM C

URI Online Judge | 1133 Resto da Divisão Adaptado por Neilor Tonin, URI   Brasil Timelimit: 1 Escreva um programa que leia 2 valo...