Nine : There are three rows, three columns, nine squares, from 1 to 9 a total of nine numbers are not filled in these nine squares, with the condition that two numbers are equal to each row, column, three diagonal.
The following is implemented in Java nine Gongge:
Public classninetable { Public Static void Main(string[] args) {intArr[][] =New int[3][3];intA =2;intb =3/2; for(inti =1; I <=9; i++) {arr[a++][b++] = i;if(0= = i%3) {a = a-2; B = B-1; }Else{a = a%3; b = b%3; }} System. out. println ("Output:"); for(inti =0; I <3; i++) { for(intj =0; J <3; J + +) {System. out. print (Arr[i][j] +" "); } System. out. Print ("\ n"); } }}
Run on Linux:
$javac NineTable.java$java NineTableoutput:492357816
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Implementing the nine grid in Java