Home > Back-end >  Consult bosses how much time and space complexity of the program are respectively, the other should
Consult bosses how much time and space complexity of the program are respectively, the other should

Time:12-20

# define _CRT_SECURE_NO_WARNINGS
# include & lt; Stdio. H>
# define N 10
Void reverse (int [p], int left, int right)//data reverse order
{
Int temp.
While (left & lt; Right)
{
Temp=p [left];
P=[left] p [right].
P [right]=temp;
Right -; Left++;
}
}
Void sort1 (int [p], int left, int right)//will be a set of is... The positive and negative... Negative transposition in order
{
int i=0;
The reverse (p, left, right);
While (p [i++] <{0); }
Reverse (p, left, I - 2);
The reverse (p, I - 1, right);
}
Void CompletelySort (int * p, int left, int right)//the whole array is negative in the former, a positive number in the back and don't change the order of the original array
{
Int I=0, j=0;
While (left & lt; Right& & J<=N)
{
While (p [left++] <{0); }
Left=left - 1;
J=left;
While (p [j++] & gt; {0); }
Sort1 (p, left, j - 1);
}
}
The main ()
{
Int a []={1, 2, 3, 4, 6, 7, 9, and 10,7,22, - 78};
Int right=N;
for (int i=0; I & lt;=right; I++)
{
Printf (" % d ", a [I]);
}
CompletelySort (a, 0, right);
Puts (" \ n ");
For (int q=0; Q & lt;=right; Q++)
{
Printf (" % d ", a [q]);
}
}
  • Related