SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const io = require('console-read-write');
  2.  
  3. async function main() {
  4.     const nAndm = await io.read();
  5.  
  6.     const matrix = [];
  7.     let i = 0;
  8.     while (i !== m) {
  9.         io.write('Enter Numbers:');
  10.         let numbers = await io.read();
  11.         let numbersSplit = numbers.split(" ");
  12.         let j = [];
  13.         for(let a = 0;a <= numbersSplit.length-1 ; a++){
  14.             j.push(+numbersSplit[a])
  15.         }
  16.         matrix.push(j)
  17.         i++;
  18.     }
  19.  
  20.     let zini = 0;
  21.     for(let row = 1; row < matrix.length-1; row++){
  22.         for(let column = 1; column < matrix[row].length-1; column++){
  23.             let thisNumber = matrix[row][column];
  24.             let left = matrix[row][column-1] , right = matrix[row][column+1] , top = matrix[row-1][column] , bottom = matrix[row+1][column];
  25.             if(
  26.                 (thisNumber > right && thisNumber >left && thisNumber<top && thisNumber<bottom)
  27.                 ||
  28.                 (thisNumber < right && thisNumber < left && thisNumber>top && thisNumber>bottom)
  29.             ) zini++;
  30.         }
  31.        
  32.     }
  33.     io.write(zini);
  34.    
  35. }
  36.  
  37. main();
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