Advertisement
blvkparis

Task

Dec 14th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int a = scanner.nextInt();
  7.         boolean flag = false;
  8.         boolean asc = true;
  9.         while(scanner.nextInt() != 0)
  10.         {
  11.             int b = scanner.nextInt();
  12.             if (b >= a && asc == true)
  13.             {
  14.                 a = b;
  15.                 flag = true;
  16.                 asc = true;
  17.                 continue;
  18.             }
  19.             else
  20.             {
  21.                 asc = false;
  22.             }
  23.             if (b <= a && asc == false)
  24.             {
  25.                 a = b;
  26.                 flag = true;
  27.                 continue;
  28.             }
  29.             else
  30.             {
  31.                 flag = false;
  32.                 break;
  33.             }
  34.         }
  35.         System.out.println(flag);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement