// Monotonic Sequence // import java.util.Scanner; public class Program3 { public static void main(String[] args) { Scanner scan= new Scanner(System.in); int[] s = {1, 2, 4, 5, 7, 8, 9, 12, 15}; //int[] s = {1, 2, 4, 5, 3, 8, 9, 12, 15}; int idx=-1; // index of the fists entry which breaks the monotinicity for(int i=1; i< s.length; i++) { if(s[i] < s[i-1]) { idx=i; break; } } if(idx != -1){ System.out.println("The sequence is NOT monotonic."); System.out.println("The monotonicity is broken at index " + idx); } else System.out.print("The sequence is monotonic."); } }