CSP题解|201604-1 折点计数|100分
#include <bits/stdc++.h> using namespace std; int main() { int n,temp,res=0; cin>>n; vector<int>v; while(n--){ cin>>temp; v.push_back(temp); } for(int i =1;i<v.size()-1;i++){ if((v[i]>v[i-1] && v[i]>v[i+1])||(v[i]<v[i-1] && v[i]<v[i+1]))res++; } cout<<res<<endl; }