A two-dimensional array of Java arrays minesweeper instance

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.