Title Description
In an array of integers, an integer that is subscript I, if it is greater than all of its adjacent integers, or is less than all of its adjacent integers, is called the extremum point.
Input requirements
There is 2xn+1 line input: The first line is the number of arrays to be processed n; for the remaining 2xn rows, each 2 rows represents an array. The first line is the number of elements in this array K (4≤k≤80), and the second row is the K integer.
Output requirements
The output is N rows: Each line corresponds to the subscript value of all extremum points in the corresponding array, and the subscript values are separated by a space.
If the input
31010 12 12 11 11 12 23 24 12 121512 12 122 112 222 211 222 221 76 36 31 234 256 76 761512 14 122 112 222 222 222 221 76 3 6 31 234 256 76 73
should be output
0 72 3 4 5 6 10 120 2 3 10 12 14
1#include <stdio.h>2#include <stdlib.h>3   intMain ()4 {  5     intn,i,j,a[ the],flag,m; 6   7      while(SCANF ("%d", &m)! =EOF)8     {  9          for(i=0; i<m;i++)  Ten         {   Onescanf"%d",&N);  A              for(j=0; j<n;j++)   -scanf"%d",&A[j]);  -    theflag=0;  -              for(j=0; j<n;j++)   -             {   -                 if((j==0&&a[0]!=a[1])|| (j==n-1&&a[j]!=a[j-1])|| (a[j]>a[j-1]&&a[j]>a[j+1])|| (a[j]<a[j-1]&&a[j]<a[j+1]))   +                 {   -                     if(flag==1)   +printf"%d", J);  A                     Else   at                     {   -printf"%d", J);  -flag=1;  -                     }   -                 }   -             }   in    -printf"\ n");  to         }   +     }   -     return 0;  the}
Print Extreme point subscript