You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
513 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[1000] = {0};
int guaidianCount = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n - 1; i++) {
if (a[i] - a[i - 1] > 0 && a[i + 1] - a[i] < 0) {
guaidianCount++;
}
if (a[i] - a[i - 1] < 0 && a[i + 1] - a[i] > 0) {
guaidianCount++;
}
}
cout << guaidianCount << endl;
return 0;
}