import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
int result =0;
for(int i =0;i<n;i++){
a[i] = in.nextInt();
}
for(int i =0;i<n;i++){
if(i>0 && i<n-1){
//凹折点
if(a[i-1] > a[i] && a[i+1] > a[i])
result ++;
//凸折点
if(a[i-1] < a[i] && a[i+1] < a[i])
result ++;
}
}//for
System.out.print(result);
}//main
}//Main
16-04-01(折点计数)
猜你喜欢
转载自blog.csdn.net/qq_51985653/article/details/121502933
今日推荐
周排行