struct {
double balance;
char names[];
}
i need to sort an array of these structs first by name ( names is an array of first,last) alphabetically, and then balance in decending order
I need a recersive C++ quick sort algorithm.?
Just search on "quicksort algorithm C++" I found the following:
http://yagni.com/combsort/index.php
http://en.wikipedia.org/wiki/Quicksort
http://mathbits.com/mathbits/compsci/Arr...
...
Reply:What grade are you in? You need this 1 kid @ my school. A total supergenius.
Reply:Ok well I just finished with arrays and structs last semester- and they got me- but I can try to help. First in your array names...you will have to have names.first and names.last. That is the only way you will be able to access each individual item in the array. You will use the code bubble sort for this- which i have listed below. This will sort the names using the ascii codes and comparing each letter with the code and then sort in decending order.
{
string temp;
for (int i = 0; i %26lt; count-1 ; i++)
{
for (int j = 0; j %26lt; count - (i+1); j++)
{
if(list[j] %26gt; list[j+1])
{
temp = list[j];
list[j] = list[j+1];
list[j+1] = temp;
}
}
}
}
If you use this format- and maybe switch the list[j] with maybe names.first and then another function using this bubblesort with names.last could help. like I said i dont know too much about what you are trying to do. hope it helps you tho
Reply:c + g + me
i don't know. i'm just tryin'. i'm really dumb at this but i'd like to be smart.
Reply:WHY DONT YOU ASK YOUR TEACHER
Reply:english, please?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment