Home > Back-end >  charushu
charushu

Time:10-26

#include
Void main ()
{
Int a [10], I, j, k;
Int x, d=0, h=9, m, temp.
for(i=0; i<10; I++)
The scanf (" % d ", & amp; A [I]);
for(i=0; i<9. I++)
for(j=0; J<=8 - I; J++)
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A [j]=a, a + 1 bonus to [j].
A=\ [j + 1];
}
Printf (" output number is: \ n ");
for(i=0; i<10; I++)
Printf (" % d \ n ", a [I]);
The scanf (" % d ", & amp; X);
While (d<=h)
{
M=(d + h)/2;
If (x==[m] a) break;
Else if (x> A [m])
D=m + 1;
The else h=m - 1;
}
If (d<=h) printf (" % d ", x);
The else
{
for(k=0; k<=8 & amp; & x> A, [k]. K++)
for(i=9; I>=k; I -)
{
A [k]=x;
A [I + 1)=a, [I].
}
}
for(k=0; k<11. K++)
Printf (" % d \ n ", a [k]);
}

CodePudding user response:

The insert part can write
 
Int k;
For (k=0; k<10; K++)
If (a [k] & gt; X)
break;
For (int j=9; J>=k; J++)
A [j + 1)=a, [j].
A [k]=x;

In addition, the array should define a bigger, or insert a number of words, will lead to cross-border access

CodePudding user response:

Program and fault point, after the x input results in 2 the value of x and x is it replaced a number behind

CodePudding user response:

Mobile data first, and then write the value of x
  • Related