Problem description

   given n An integer represents a store n Sales volume per day . If by one day sales were growing , The day after that, sales dropped , This day is called the break point , On the other hand, if the previous sales decrease, the next day sales increase , This day is also called the break point . No other day is a break point .
   given n An integer a1, a2, …, an Represents sales volume , Please calculate the total number of discount points these days .
   In order to reduce ambiguity , Our given data guarantee : Here it is n The sales volume of two consecutive days in a day is always different , Namely ai-1≠ai. be careful , If two days are not adjacent , Sales may be the same .

Input format

   The first line of input contains an integer n.
   The second line contains n An integer , Separate with spaces , Respectively a1, a2, …, an.

Output format

   Output an integer , Indicates the number of break points .

sample input

5 4 1 2 3 6 4

sample output


Scale and convention of evaluation case

        All evaluation cases meet :1 ≤ n ≤ 1000, The daily sales volume is no more than 10000 Nonnegative integers of .

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm>
#include<cmath> using namespace std; const int N=1000+10; int a[N],n; int
main() { scanf("%d",&n); scanf("%d%d",&a[0],&a[1]); int ans=0; for(int
i=1;i<n-1;i++) { scanf("%d",&a[i+1]);
if(a[i]<a[i-1]&&a[i]<a[i+1]||a[i]>a[i-1]&&a[i]>a[i+1]) ans++; }
printf("%d\n",ans); return 0; }



©2020 ioDraw All rights reserved
Java exercises 1: Simply define a car class New photo album app launched by Microsoft : Using cross platform framework React Native to write Chapter two Fundamentals of programming Programming exercises pandas Time order of webpack Code segmentation import()Vue slot slot: Default slot , Named slot , Scope slot Fundamentals of data analysis ——R language ( Processing missing values )C++ Implementation of matrix meteor shower effect PostMan Advanced Usage , Interface MD5+Secret autograph Sign The 12th Blue Bridge Cup B group C/C++ Provincial competition