SHARE
TWEET

P01_ShockWave

a guest Jun 7th, 2018 132 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Arrays;
  5.  
  6. public class P01_ShockWave {
  7.     public static void main(String[] args) throws IOException {
  8.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  9.  
  10.         String[] coordinates = reader.readLine().split(" ");
  11.         int n = Integer.parseInt(coordinates[0]);
  12.         int m = Integer.parseInt(coordinates[1]);
  13.  
  14.        int[][] matrix = new int[n][m];
  15.  
  16.         String line = reader.readLine();
  17.  
  18.         while (!"Here we go".equalsIgnoreCase(line)){
  19.             int[] commandArgs = Arrays.stream(line.split(" "))
  20.                     .mapToInt(Integer::parseInt)
  21.                     .toArray();
  22.  
  23.             int x1 = commandArgs[0];
  24.             int y1 = commandArgs[1];
  25.             int x2 = commandArgs[2];
  26.             int y2 = commandArgs[3];
  27.  
  28.             for (int i = x1; i <= x2 ; i++) {
  29.                 for (int j = y1; j <= y2; j++) {
  30.                         matrix[i][j]++;
  31.                 }
  32.             }
  33.  
  34.             line = reader.readLine();
  35.         }
  36.  
  37.         for (int[] r : matrix) {
  38.             for (int c : r) {
  39.                 System.out.print(c + " ");
  40.             }
  41.             System.out.println();
  42.         }
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top