output even numbers in reverse order


Submit solution

Points: 20
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

題目說明

<1121檢定考題,1131檢定考題>
輸入一連串數字,第1個輸入值是n表示陣列長度,第2到n+1個輸入值是陣列內容,輸入值都是大於0且小於1000的整數。
程式以相反順序輸出陣列中所有的偶數數字,而且不輸出所有奇數數字,如果沒有找到任何偶數數字,則輸出0。

輸入

一連串數字,第1個輸入值是n表示陣列長度,第2到n+1個輸入值是陣列內容,輸入值都是大於0且小於1000的整數。

輸出

以相反順序輸出陣列中所有的偶數數字,而且不輸出所有奇數數字,如果沒有找到任何偶數數字,則輸出0。

sample input1

 6 1 3 5 2 4 8

sample output1

8 4 2

sample input2

6 1 2 3 4 5 8

sample output2

8 4 2

sample input3

1 1

sample output3

 0

Comments

There are no comments at the moment.