SHARE
TWEET

Untitled

mahen6513 Jan 24th, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static void main(String[] args) throws FileNotFoundException {
  2.  
  3.         try {
  4.  
  5. //            File file = new File("ss.txt");
  6.             File file = new File("ELEVATIONS.txt");
  7.             Scanner inputFile = new Scanner(file);
  8.  
  9.             int rowsCount = 0;
  10.             int colsCount = 0;
  11.             int radius = 0;
  12.  
  13.             if (inputFile.hasNext()) {
  14.                 rowsCount = inputFile.nextInt();
  15.             } else {
  16.                 System.out.println("Error cannot read rows count");
  17.                 return;
  18.             }
  19.  
  20.             if (inputFile.hasNext()) {
  21.                 colsCount = inputFile.nextInt();
  22.             } else {
  23.                 System.out.println("Error cannot read cols count");
  24.                 return;
  25.             }
  26.  
  27.             if (inputFile.hasNext()) {
  28.                 radius = inputFile.nextInt();
  29.             } else {
  30.                 System.out.println("Error cannot read radius");
  31.                 return;
  32.             }
  33.  
  34.             int[][] elevations = new int[rowsCount][colsCount];
  35.  
  36.             for (int row = 0; row < elevations.length; row++) {
  37.                 for (int col = 0; col < elevations[row].length; col++) {
  38.                     elevations[row][col] = inputFile.nextInt();
  39.                 }
  40.             }
  41.  
  42.             inputFile.close();
  43.  
  44.             mostCommonVal(elevations);
  45.  
  46.         } catch (IOException ex) {
  47.             System.out.println(ex);
  48.         }
  49.  
  50.     }
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