链接:http://118.190.20.162/view.page?gpid=T42
代码:
#include<bits/stdc++.h>
using namespace std;
vector<int> ve;
int main (){
int n,num;
cin>>n;
for(int i=0;i<n;i++){
cin>>num;
ve.push_back(num);
}
int ans=0;
for(int i=1;i<n-1;i++){
if(ve[i]>ve[i-1]&&ve[i]>ve[i+1])ans++;
if(ve[i]<ve[i-1]&&ve[i]<ve[i+1])ans++;
}
cout<<ans;
return 0;
}