开发者

Resources needed: Sort 2D array "graphically"

开发者 https://www.devze.com 2022-12-23 05:22 出处:网络
I have a 2D array 1 2 3 4 5 6 7 8 9 and want to sort it like this Snake 1 2 3 8 9 4 7 6 5 Snake (different) 1 2 3

I have a 2D array

1 2 3

4 5 6

7 8 9

and want to sort it like this

Snake

1 2 3

8 9 4

7 6 5

Snake (different)

1 2 3

6 5 4

7 8 9

Rotated

1 4 7

2 5 8

3 6 9

Wipe (diagonal)

1 3 6

2 5 8

4 7 9

Well, you got it, all kinds of sorting.

Searching the interweb for ho开发者_C百科urs now. Any resources (specific language or pseudo code) on that greatly appreciated...


Suggestion: Dump all values in a 1D-array and sort there. Then define the patterns for filling using multiple for loops.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号