#K68227. Alternate Weights Separation
Alternate Weights Separation
Alternate Weights Separation
You are given a string consisting of space‐separated integers which represent the weights of fruits in an alternating order: the first number is the weight of an apple, the second number is the weight of an orange, the third number is again an apple’s weight, and so on. Your task is to separate the weights into two lists. In other words, if the input sequence is
then you should output the two lists:
- Apples: $$[w_{0},w_{2},w_{4},\dots]$$
- Oranges: $$[w_{1},w_{3},w_{5},\dots]$$
If the input string is empty, both lists should be empty.
inputFormat
The input consists of a single line containing space‐separated integers. These integers represent the alternating weights of apples and oranges.
outputFormat
Output two lines. The first line contains the weights of the apples separated by spaces, and the second line contains the weights of the oranges separated by spaces. If a list is empty, print an empty line.
## sample3 5 2 4 9 7
3 2 9
5 4 7
</p>