Created
May 5, 2017 02:36
-
-
Save ZaneWithSpoon/e4a5a9f3f8bbc7b7ce3cc3fa51ef2588 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
//returns the index of the starting vlue | |
int sort_list(int start, int a[]) { | |
for (int i = 0; i < 1000; ++i) | |
{ | |
sorted_addresses[i] = a[i]; | |
} | |
sorted_addresses[1000] = start; | |
int array_size = 1001; | |
int i, j, temp; | |
for (i = 0; i < (array_size - 1); ++i) | |
{ | |
for (j = 0; j < array_size - 1 - i; ++j ) | |
{ | |
if (sorted_addresses[j] > sorted_addresses[j+1]) | |
{ | |
temp = sorted_addresses[j+1]; | |
sorted_addresses[j+1] = sorted_addresses[j]; | |
sorted_addresses[j] = temp; | |
} | |
} | |
} | |
for (int i = 0; i < 1001; ++i) | |
{ | |
if (sorted_addresses[i] == start) | |
return i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment