http://www.verejava.com/?id=17159392878528
Import Java.util.scanner;public class Test1 {/** * simulation minesweeper, in a two-dimensional array, 1: No Thunder 2: Thunder, keyboard input line number and column number, determine whether to sweep the Thunder. */public static void main (string[] args) {int[][] thundes={{1,1,1,1}, {1,1,1,1}, {1,2,1,1}, {1,1,1,1}}; Scanner in=new Scanner (system.in); Keyboard input line number and column number System.out.println ("Please enter line number:"); int Row=in.nextint (); System.out.println ("Please enter the column number:"); int Col=in.nextint (); int value= thundes[row][col];//The value obtained from the array//to determine whether to sweep the ray for (int i=0;i<thundes.length;i++) {for ( int j=0;j<thundes[i].length;j++) {//Determine if value exists in the array and equals 2 if (value==thundes I [j]&&value==2) {System.out.print ("lei"); } else {System.out.print ("*"); }} System.out.println (""); } }}
http://www.verejava.com/?id=17159392878528
A two-dimensional array of Java arrays minesweeper instance