import java.util.*; public class IncSeq{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int[] arr; System.out.println("Enter array size"); int n=sc.nextInt(); arr=new int[n]; System.out.println("Enter"+ n + "elements"); for(int i=0;i<arr.length;i++){ arr[i]=sc.nextInt(); } int count=getcount(arr); System.out.println("Elements" +Arrays.toString(arr)); System.out.println("No.of increasing sequences"+count); } private static int getcount(int[] arr){ int count=0; for(int i=0;i<arr.length-1;){ boolean flag=false; while(i<arr.length-1 && arr[i]<arr[i+1]) { flag=true; i++; } if (flag) count++; else i++; } return count; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter