borkins

Exam Jan-2016 - 08. Increasing Elements

May 11th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. /**
  2.  * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _08_IncreasingElements
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int n = Integer.parseInt(console.nextLine());
  14.    
  15.         int len = 0;
  16.         int maxLen = 0;
  17.         int prevNum = Integer.MIN_VALUE;
  18.    
  19.         for (int i = 0; i < n; i++)
  20.         {
  21.             int num = Integer.parseInt(console.nextLine());
  22.        
  23.             if (num > prevNum) len++;
  24.             else len = 1;
  25.        
  26.             if (len > maxLen) maxLen = len;
  27.        
  28.             prevNum = num;
  29.         }
  30.    
  31.         System.out.println(maxLen);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment