#include <stdio.h>
#define N 1000
int main()
{
int n, i, a[N], b[N], s;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
b[0] = a[1] - a[0];
for (i = 1; i < n - 1; i++)
{
b[i] = a[i + 1] - a[i];
if (b[i] > 0 && b[i - 1] < 0) s++;
else
if (b[i] < 0 && b[i - 1]>0)
s++;
}
printf("%d", s);
return 0;
}
#CSP 201604-1 折点计数
最新推荐文章于 2021-04-02 19:58:06 发布