12-10-2009, 03:07 PM
Guess that N = is the dimmension of the array.
It will sort from the biggest element to smallest, for inversely just change the sign to "+" at the start of if circle.
I hope I help it to solve your problem.
Code:
for(int j =0; j<N; j++) {
for(int i=1; i<N; i++) {
if(array[i]>array[i-1]) {
int tmp = array[i];
array[i] = array[i-1];
array[i-1]=tmp;
}
}
}
It will sort from the biggest element to smallest, for inversely just change the sign to "+" at the start of if circle.
I hope I help it to solve your problem.