Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array Help[C++]
#2
Guess that N = is the dimmension of the array.

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.
Reply


Messages In This Thread
Array Help[C++] - by se7en - 12-10-2009, 08:45 AM
RE: Array Help[C++] - by geeK - 12-10-2009, 03:07 PM
RE: Array Help[C++] - by Sagittarius - 12-11-2009, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  2D Array Editor. InfamousKnight 0 609 03-11-2011, 07:11 PM
Last Post: InfamousKnight
  Something absurdly wrong with char array J4P4NM4N 2 1,050 11-29-2009, 04:36 PM
Last Post: J4P4NM4N

Forum Jump:


Users browsing this thread: 3 Guest(s)