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
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
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
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;
}
}
}
many thanks my lord, your help is invaluble
No problem, that's what this forum is for ;)
just call him lord of the protoss
Preator perhaps... :)Quote:
Originally posted by frenchfry164
just call him lord of the protoss