#K36062. Group Numbers by Even and Odd
Group Numbers by Even and Odd
Group Numbers by Even and Odd
Problem Description
You are given a list of integers. The first line of input contains a single integer n which indicates the number of integers in the list. The second line contains n space-separated integers.
Your task is to separate the numbers into two groups: even and odd. You must maintain the order of appearance from the input for both groups.
Output Specification:
- In the first line, print the even numbers separated by a single space. If there are no even numbers, print an empty line.
- In the second line, print the odd numbers separated by a single space. If there are no odd numbers, print an empty line.
Note: All numbers, including negatives and zero, follow the same parity rules.
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains a single integer n, the number of integers.
- The second line contains n space-separated integers.
outputFormat
The output should be printed to stdout in two lines:
- The first line should list all even numbers separated by a single space. If there are no even numbers, output an empty line.
- The second line should list all odd numbers separated by a single space. If there are no odd numbers, output an empty line.
10
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10
1 3 5 7 9
</p>