mstoyanova

Untitled

Mar 16th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. public class IsArrayInWaveFrom {
  2.     public static void main(String[] args) {
  3.         Scanner scanner = new Scanner(System.in);
  4.         String input = scanner.nextLine();
  5.         String [] arr = input.split(" ");
  6.         Integer [] arryInt = new Integer[arr.length];
  7.         String wave ="";
  8.  
  9.         for (int i = 0; i < arr.length ; i++) {
  10.             arryInt[i] = Integer.parseInt(arr[i]); } // filling the Int array
  11.         for (int i = 1 ; i < arryInt.length; i+=2) {
  12.             for (int j = 2; j < arryInt.length; j++) {
  13.                 if (arryInt[i - 1] > arryInt[i]) {
  14.                     if (arryInt[j - 1] < arryInt[j]) {
  15.  
  16.                         wave = "Yes";
  17.  
  18.                     }
  19.  
  20.                 } else {
  21.                 wave = "No";
  22.             }
  23.             }
  24.         }
  25.  
  26.         System.out.println(wave);
  27.         }
  28.  
  29.     }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment