Skip to content

Instantly share code, notes, and snippets.

@lzzy12
Created November 16, 2018 11:53
Show Gist options
  • Save lzzy12/d313d545c53dab2bd93e229b16eece61 to your computer and use it in GitHub Desktop.
Save lzzy12/d313d545c53dab2bd93e229b16eece61 to your computer and use it in GitHub Desktop.
void arrange(int arr[], int size){
int positive[10], index_p = 0, index_n = 0;
for(int i = 0; i < size; i++)
{
if(arr[i] < 0)
{
if(i <= index_p-1)
positive[index_p] = arr[index_n];
arr[index_n] = arr[i];
index_n++;
}
else
{
positive[index_p] = arr[i];
index_p++;
}
}
index_p = 0;
for(int j = index_n; j < size; j++){
arr[j] = positive[index_p];
index_p++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment