Alright, i've been using bubble sort, i found some code on Cprogramming.com, but i can't figure out how to modify it to work in descending order.
Its sorting a Pointer array. (int** array = new int*[n])
IntPtr is declared as int*.
n is the size of the array...
Yahoo was being stupid and taking away my new lines, so, if it does it again, the '...' means its a new line, this is just incase
:::CODE BEGIN:::
...void sortDown(IntPtr* array, int n)
... {
... for(int x = 0; x < n; x++)
... {
... for(int y = 0; y < n - 1; y++)
... {
... if(*array[y] > *array[y+1])
... {
... IntPtr temp = array[y+1];
... array[y+1] = array[y];
... array[y] = temp;
... }
... }
... }
...}
Now i need to create a function called sortUp, same parameters as the first one, still void, but it needs to sort it in descending order
2006-12-10
12:29:58
·
3 answers
·
asked by
duffusd
3
in
Computers & Internet
➔ Programming & Design