#K78157. Number Categorization Challenge
Number Categorization Challenge
Number Categorization Challenge
Given a list of integers, write a program that categorizes each integer as either Even or Odd and outputs them in a specific format.
For each number, if it satisfies \( n \mod 2 = 0 \) (i.e. \( n \) is even), label it as "Even"; otherwise, label it as "Odd". Each number-label pair should be formatted as number (Label)
and pairs should be separated by a comma and a space.
If the list is empty, output an empty line.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a non-negative integer N, the number of elements in the list.
- The second line contains N space-separated integers. If N is 0, the second line may be empty.
outputFormat
Output to standard output (stdout) a single line that contains the formatted list of numbers. Each number should be followed by its label in the format number (Even/Odd)
, and numbers should be separated by a comma and a space. If the list is empty (i.e. N is 0), output an empty line.
5
1 2 3 4 5
1 (Odd), 2 (Even), 3 (Odd), 4 (Even), 5 (Odd)