Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter thе amount of numbers: ");
- int n = Integer.parseInt(sc.nextLine());
- int countCurrentLongest = 0;
- int countLongest = 0;
- int aPrev = 0;
- int num = 0;
- for(int i =0;i<n;i++){
- num = Integer.parseInt(sc.nextLine());
- if(num > aPrev){
- countCurrentLongest++;
- }
- else{
- countCurrentLongest = 1;
- }
- if(countCurrentLongest > countLongest){
- countLongest = countCurrentLongest;
- }
- aPrev = num;
- }
- System.out.println("The longest sequence of increasing numbers is: "countLongest);
- }
- }
Add Comment
Please, Sign In to add comment