-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10PrintExtremePoint1126.cpp
52 lines (48 loc) · 1.08 KB
/
10PrintExtremePoint1126.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
using namespace std;
//pay attention to presentation error!
int main()
{
int n,k;//n:arr number; k:element number
int arr[80];
bool flag =0;
while(cin>>n)
{
for(int j=0; j<n; j++)
{
cin>>k;
flag=0;
for(int i=0; i<k; i++)
{
cin>>arr[i];
}
if(arr[0]!=arr[1])
{
cout<<"0";
flag=1;
}
for(int m=1; m<k-1; m++)
{
if((arr[m]>arr[m-1]&&arr[m]>arr[m+1])||(arr[m]<arr[m-1]&&arr[m]<arr[m+1]))
{
if(flag)
cout<<" "<<m;
else
{
cout<<m;
flag=1;
}
}
}
if(arr[k-2]!=arr[k-1])
{
if(flag)
cout<<" "<<k-1;
else
cout<<k-1;
}
cout<<endl;
}
}
return 0;
}