Magic Cube Procedure (3 * 3)

xiaoxiao2021-03-06  38

// Magic Maze 3 * 3 # include void main (void) {static a [3] [3] = {0, 0, 0}, {0, 0, 0}, {0,0 , 0}}; int indexx = 0, indexy = 1, tmpx = 0, tmpy = 0, i = 1; // first deal with a [0] [1]. A [indexx] [indexy] = i;

While (i <10) {TMPX = indexx; tmpy = indexy; indexx -; IF (indexx <0) indexx = 2; if (INDEXX> 2) indexx = 0; IF (INDEXY <0) indexy = 2 ; If (indexy> 2) indexy = 0; if (a [indexx] [indexy]! = 0) {indexx = tmpx; indexy = tmpy; indexx ; IF (INDEXY> 2) indexy = 0;} i ; a [ Indexx] [indexy] = i;} for (indexx = 0; indexx <3; indexx ) {for (indexy = 0; indexy <3; indexy ) {cout << a [indexx] [indexy] << " } Cout << endl;

}

转载请注明原文地址:https://www.9cbs.com/read-68999.html

New Post(0)