Hey all!!

i've tried every possible combo for outputing arrays lowest umber to highest number and i'm stumped..can anyone out there give me the basic format..how many for loops ..ect? really stumped here, would appreciate any help

thanks

Printable View

- 03-31-2002Unregisteredarrays
Hey all!!

i've tried every possible combo for outputing arrays lowest umber to highest number and i'm stumped..can anyone out there give me the basic format..how many for loops ..ect? really stumped here, would appreciate any help

thanks - 03-31-2002Unregistered
i guess i should be a little more specif, i have to compare to arrays, but to do that i need to put them both in numerical order, lowest to highest or vive versa, the comparing i have no probs with, its just the dang arranging lol.. oh well thanks again if anyone gets a chance to reply

- 03-31-2002Magos
This sorts the array with the largest number first:

Code:`int i,j,temp;`

//Loop through every number except the last

for(i=0; i<(NrOfElements-1); i++)

{

//Loop through every number after i

for(j=(i+1); j<NrOfElements; j++)

{

//If a higher number is located after a lower, switch

if(Array[i]<Array[j])

{

//Switch the values

Temp=Array[i];

Array[i]=Array[j];

Array[j]=Temp;

}

}

}

- 03-31-2002Unregistered
many thanks my lord, your help is invaluble

- 03-31-2002Magos
No problem, that's what this forum is for ;)

- 03-31-2002frenchfry164
just call him lord of the protoss

- 03-31-2002MagosQuote:

*Originally posted by frenchfry164*

**just call him lord of the protoss**