转载于: http://www.verejava.com/?id=17159392878528 ,
<前> import java.util.Scanner public class  Test1 {/* * ,*模拟扫雷游戏,,在一个二维数组中,,1:无雷,2:有雷,,键盘输入,行号和列号,,判断是否扫到了雷又是; ,*/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 拷贝=,new 扫描仪(系统);//键盘输入,行号和列号 System.out.println(“请输入行号:“);int row =, in.nextInt (); System.out.println(“请输入列号:“);int col =, in.nextInt ();int value =, thundes(行)(col);//从数组中获得的值//判断是否扫到了雷 for (int 小姐:=,0;,小姐:& lt;, thundes.length;,我+ +),{for (int j =, 0;, j & lt;, thundes[我]. length;, j + +),{//判断,value 是否在,数组中存在,并且,等于,2 if (value ==, thundes[我][j],,,, value ==, 2), { System.out.print(“雷“); },{else System.out.print (“*,“); } } System.out.println (“;”); } } } >之前转载于: http://www.verejava.com/?id=17159392878528 ,