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
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; } } }
Last edited by Magos; 03-31-2002 at 12:54 PM.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
many thanks my lord, your help is invaluble
No problem, that's what this forum is for
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Preator perhaps...Originally posted by frenchfry164
just call him lord of the protoss
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.