Hello everyone here. Im new and yes that is my homework im not going to lie.

I need to write a program that doen't exactly sort an array. I will give an example

If i have that array : 1,3,0,2,0,-1,0,-2,-4,0

After transformations... the same array must be -1,-2,-4,0,0,0,0,1,3,2

The numbers<0 in the left part

The numbers == 0 in the middle

The numbers > 0 after the nulls in the right part.

Okay here is the problem. I must use only one array.

I can do it to make the program to this point -1,-2,-4,0,0,0,0 but with the positive numbers i've got a big problem . Here is my code.

and the output isCode:#include <iostream.h> int main() { const int K=10; int array[K]={1,3,0,2,0,-1,0,-2,-4,0},i,b=0,m; for(i=0;i<K;i++) cout << array[i] << " "; cout << endl; for(i=0;i<K;i++) if(array[i]<0) { m=array[b]; array[b]=array[i]; array[i]=m; b++; } for(i=b;i<K;i++) if(array[i]==0) { m=array[b]; array[b]=array[i]; array[i]=m; b++; } for(i=0;i<K;i++) cout << array[i] << " "; cout << endl; return 0; }

... 3 1 2 It must be 1 3 2.Code:1 3 0 2 0 -1 0 -2 -4 0 -1 -2 -4 0 0 0 0 3 1 2

Sorry for my english. Im not native.

I would be happy if you give me some ideas.

Please help me.