URI Online Judge | 1066
Pares, Ímpares, Positivos e Negativos
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
Leia 5 valores Inteiros. A seguir mostre quantos valores digitados foram pares, quantos valores digitados foram ímpares, quantos valores digitados foram positivos e quantos valores digitados foram negativos.
Entrada
O arquivo de entrada contém 5 valores inteiros quaisquer.
Saída
Imprima a mensagem conforme o exemplo fornecido, uma mensagem por linha, não esquecendo o final de linha após cada uma.
URI Online Judge | 1066
Even, Odd, Positive and Negative
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
Make a program that reads five integer values. Count how many of these values are even, odd, positive and negative. Print these information like following example.
Input
The input will be 5 integer values.
Output
Print a message like the following example with all letters in lowercase, indicating how many of these values areeven, odd, positive and negative.
#include <stdio.h>
int main() {
int A,B,C,D,E,F;
A = 5;
C = 0;
D = 0;
E = 0;
F = 0;
while(A--){
scanf("%d", &B);
if (B < 0)
D++;
else if (B > 0)
C++;
if (B % 2 == 0)
E++;
else
F++;
}
printf("%d valor(es) par(es)\n", E);
printf("%d valor(es) impar(es)\n", F);
printf("%d valor(es) positivo(s)\n", C);
printf("%d valor(es) negativo(s)\n", D);
return 0;
}
Nenhum comentário:
Postar um comentário