#C13116. Separate Even and Odd Numbers
Separate Even and Odd Numbers
Separate Even and Odd Numbers
Given a list of integers, separate the list into two lists: one containing even numbers and the other containing odd numbers. A number \(n\) is considered even if \(n \equiv 0 \pmod{2}\) and odd otherwise.
Your task is to read an integer \(n\) (the number of elements) followed by \(n\) integers. Then, output two lines: the first line should list all even numbers (in their original order) separated by a space, and the second line should list all odd numbers separated by a space. If there are no even or no odd numbers, print an empty line for that case.
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\) indicating the number of integers.
- The second line contains \(n\) space-separated integers.
outputFormat
Output two lines:
- The first line should contain the even numbers separated by a space (or an empty line if none exist).
- The second line should contain the odd numbers separated by a space (or an empty line if none exist).
9
10 15 2 8 23 34 55 60 71
10 2 8 34 60
15 23 55 71
</p>