Advertisement
porteno

Q1

Dec 7th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public class Q1 {
  2. public static void main(String[] args) {
  3. int[] a = {3,6,-12,-8,-37,-6,2,-9,13};
  4. int n = 9;
  5. int ans = 0;
  6. int i = 0;
  7. while (i < n-2)
  8. {
  9. if ((a[i+1] > a[i]) && (a[i+1]>a[i+2]))
  10. ans++;
  11. i=i+2;
  12. }
  13. System.out.println(ans);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement