NLKappa

половина сапёра, и та неправильная

Oct 11th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         int x1;
  7.         int y1;
  8.         Scanner sc = new Scanner(System.in);
  9.         System.out.println("Введите длину поля по координате x: ");
  10.         int x = sc.nextInt();
  11.         System.out.println("Введите длину поля по координате y: ");
  12.         int y = sc.nextInt();
  13.         int arr[][] = new int[x][y];
  14.         System.out.println("Введите кол-во мин на поле: ");
  15.         int m = sc.nextInt();
  16.         for (int i = 0; i < m; i++) {
  17.             System.out.printf("Введите координату х мины номер %d: ", i + 1);
  18.             x1 = sc.nextInt();
  19.             System.out.printf("Введите координату y мины номер %d: ", i + 1);
  20.             y1 = sc.nextInt();
  21.             arr[x1][y1] = 1;
  22.         }
  23.         for (int j = 0; j < x; j++) {
  24.  
  25.             for (int k = 0; k < y; k++) {
  26.                 System.out.print(arr[k][m] + " ");
  27.             }System.out.println();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment