Created
April 14, 2016 22:22
-
-
Save dominicknguyen/738aeb3ebadf2e58b89b26ab77963f1c to your computer and use it in GitHub Desktop.
!!
This file contains 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
int[] sort(int[] a, int num) { | |
for(int z = a.length -1; z > 1; z--) { | |
if(a[z] == num) { | |
int temp = a[0]; | |
a[0] = num; | |
a[z] = temp; | |
} | |
if(a[z] < a[z - 1]) { | |
int temp = a[z]; | |
a[z] = a[z-1]; | |
a[z- 1] = temp; | |
} | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moves target number to 0. Sorts remaining elements