Um, anyone know how to control a Bubble Sort algorithm with a bool flag?
Code:
if (choice == 1)
{
//same comments from sort_array apply here
for (unsigned short x = 0; x <= computer_count; x++)
{
for (unsigned short j = 0; j < computer_count - 1; j++)
{
if (computer[j].Brand > computer[j+1].Brand)
{
//This method of swapping is MUCH nice than using multiple arrays
compdef temp; //create temporary struct
temp = computer[j+1]; //copy entire struct
computer[j+1] = computer[j];
computer[j] = temp;
//swap values around
}
}
}
So that code like that would exit when there are no more swaps, instead of brute force going through all the iterations of the outer FOR loop?
__________________
I turn away with fear and horror from this lamentable sore of continuous functions without derivatives. --
Charles Hermite
Fakelife.com Nothing to do with archery anymore. Porsche/BMW/Ferrari/Honda videos