矩阵旋转操作是为了将其它三个方向的移动都转换为向上的移动操作。向下、向左、向右转换为向上操作时,数组需要进行翻转操作参考正文代码。执行代码123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687packagemainimport"fmt"typeg2048 [4][4]intfunc(t *g2048)MirrorV() {tn :=new(g2048)fori, line :=ranget {forj, num :=rangeline {tn[len(t)-i-1][j] = num}}*t = *tn}func(t *g2048)Right90() {tn :=new(g2048)fori, line :=ranget {forj, num :=rangeline {tn[j][len(t)-i-1] = num}}*t = *tn}func(t *g2048)Left90() {
...
继续阅读
(3)