Matrix Snake


Submit solution

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types

題目說明

以S形的方式印出陣列中的所有元素

輸入

二維陣列的橫列(row)長度、直行(column)長度,輸入值皆為大於0之整數,
以及陣列的所有元素(依序輸入每一橫列),輸入值皆為整數。

輸出

S形的方式印出陣列中的所有元素,
由上而下(↓)印出第0直行,再由下而上(↑)印出第1直行,然後由上而下(↓)印出第2直行,
依此類推。

sample input0

3 3
1 2 3
4 5 6
7 8 9

sample output0

1 4 7 8 5 2 3 6 9

說明:第0行由上而下是1 4 7,第1行由下而上是8 5 2,第2行由上而下是3 6 9。

sample input1

3 4
5 6 8 8
8 8 8 2
7 3 6 8

sample output1

5 8 7 3 8 6 8 8 6 8 2 8

sample input2

2 1
3
4

sample output2

3 4

Comments

There are no comments at the moment.