Advertisement
SUni2020

IncreasingElements

Mar 28th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class increasingElements {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7. int n = Integer.parseInt(scanner.nextLine());
  8.  
  9. int countLong = 0;
  10. int countTempLong = 0;
  11. int num = 0;
  12. int numPerv = 0;
  13.  
  14. for (int i = 1; i <= n; i++) {
  15. num = Integer.parseInt(scanner.nextLine());
  16. if (num > numPerv) {
  17.  
  18. countTempLong++;
  19. } else {
  20. countTempLong = 1;
  21. }
  22. numPerv = num;
  23. if (countTempLong > countLong) {
  24. countLong = countTempLong;
  25. }
  26.  
  27. }
  28.  
  29. System.out.println(countLong);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement