Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //thanks God For Every Thing!
- //contest link:
- #include<bits/stdc++.h>
- #define pi acose(-1)
- typedef long long int ll;
- typedef double dl;
- using namespace std;
- const int mx = 1e4+5;
- int main()
- {
- int n, i;
- int arr[10005];
- while(cin>>n && n!=0)
- {
- for(i=0; i<n; i++)
- {
- cin>>arr[i];
- }
- int cnt=0;
- for(i=0; i<n; i++)
- {
- if(arr[i]>arr[i+1])
- {
- if(arr[i+1]<arr[i+2])
- {
- cnt++;
- }
- }
- if(arr[i]<arr[i+1])
- {
- if(arr[i+1]>arr[i+2])
- {
- cnt++;
- }
- }
- }
- cout<<cnt<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment