Print Extreme point subscript

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.