本帖最後由 none_and_none 於 2019-7-29 15:13 編輯

先由砌個array入手

[[1, 2, 3, 4],
[2, '', '', 5],
[1, '', '', 6],
[0, 9, 8, 7]]

arr[0][0] = 1
arr[0][1] = 2
arr[0][2] = 3
arr[0][3] = 4

arr[1][3] = 5
arr[2][3] = 6

arr[3][3] = 7
arr[3][2] = 8
arr[3][1] = 9
arr[3][0] = 0

arr[2][0] = 1
arr[1][0] = 2

咁樣會唔會容易d諗到?

TOP

arr[0][0] = 1
arr[0][1] = 2
arr[0][2] = 3
arr[0][3] = 4

arr[1][3] = 5
arr[2][3] = 6

arr[3][3] = 7
arr[3][2] = 8
arr[3][1] = 9
arr[3][0] = 0

arr[2][0] = 1
arr[1][0] = 2
none_and_none 發表於 2019-7-28 18:43

可以見到array index係有pattern
然後就用四個loop順序去做上,右,下,左

點樣print個array出離,應該唔駛教啦掛

TOP