Even numbers go first

Report a typo

Write a program that reads numbers and stores them in a deque. Any even number should be added as the first element, an odd number as the last. Then the program must output all elements from the first to the last.

The first line contains the number of elements. Each line followed the first one contains an element.

Sample Input 1:

4
1
2
3
4

Sample Output 1:

4
2
1
3
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic