#include
#include
# define N 12
Int main ()
{
An int array [N]={,52,35,12,58,78,90,587,21,0, 96-65106};
Int * PTR, I;
Printf (" sorted before the array is: \ n ");
For (PTR=array; Ptr
Int temp.
for(i=0; I
{
Temp=* PTR.
* PTR=* (PTR + 1);
* (PTR + 1)=temp;
}
Printf (" \ n sorted array is: \ n ");
For (PTR=array; Ptr
printf("\n");
system("pause");
An int array [N].
Int x=90;
Int the location;
Int bottom=0;
Int top=N - 1;
Int mid;
Int flag=0;
While (bottom<=top)
{
Mid=(bottom and top)/2;
If (array (mids)==x)
{
Location=mid;
Flag=1;
break;
}
Else if (array (mids) & gt; X)
Top=mid - 1;
The else
Bottom=mid + 1;
}
If (flag==0)
Printf (" does not exist! \n");
The else
Printf (" % d position in the array is: % d \ n ", x, the location + 1);
system("pause");
return 0;
}
CodePudding user response:
system("pause"); Behind, you declare an array, the array should be put in front of you it sorted array blocked, so you're quite so in an uninitialized array, 90 must be found,