Home > Back-end >  Enter a number in from big to small rules into the already sorted array (array from big to small ord
Enter a number in from big to small rules into the already sorted array (array from big to small ord

Time:12-10

#include
Void main ()
{
Int I, n, a [6]=,3,5,7,9 {1};
Printf (" please enter the insertion of the array number: ");
The scanf (" % d ", & amp; N);
for(i=4; I>=0; I -) //since a [4], and n forward than call the
{
If (n//qualified to a [I] back
{
A [I + 1)=a, [I].
If (I==0) //if the input number is less than the smallest in the array, will be a [0] assignment for n
A [0]=n;
}
The else
{
A [I + 1)=n.//n between array maximum minimum number at this time, a [I] break;
}
}
for(i=0; i<6; I++)
Printf (" % 4 d ", a [I]);
}

CodePudding user response:

  • Related