Created
November 16, 2018 11:53
-
-
Save lzzy12/d313d545c53dab2bd93e229b16eece61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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