Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Arbitrarily input 10 pieces of plastic data from the keyboard (the data is ordered, and half of the data is searched) to find out whether the data exists; If so, output its location?
Arbitrarily input 10 pieces of plastic data from the keyboard (the data is ordered, and half of the data is searched) to find out whether the data exists; If so, output its location?
# include & ltstdio.h & gt

void main()

{ int i,x,a[ 10],pos,low,high,mid

Printf ("Please enter data in descending order: \ n");

for(I = 0; I< 10; i++)

{ scanf("%d ",& ampa[I]);

}

Printf ("Please enter the data you want to find:");

scanf("%d ",& ampx);

pos =- 1;

Low = 0;

Height = 9;

do

{mid = high+low/2;

if(x & gt; A [middle]

? Low = mid+1;

else if(x & lt; A [middle]

? High = medium1;

other

{ pos = mid

? Break;

}

}

while(low & lt; = high);

If (pos! =- 1)

Printf ("subscript position of data: %d", POS);

Else printf ("Not found!" );

}