-
Did you say beer ? ... actually a good ol' glass of iced tea would probably do much better.
To get rid of the duplicate display. At the end of LoadArray(), you have a call to DisplayArray():
length = counter-1;
sorted = false;
DisplayArray(list,length); //delete this line
>I could probably do a lot of those couts through the switch statements, is there any preference on how that is done?
I agree with you, for example the Smallest(), Largest(), and Average() functions. Since you are returning the value anyway, why not print it in ProcessChoice? Of course with the Sort() function, the way you have done it is best.
-
infinite loop
Ice tea it is, sweet tea of course.
I am about to try the file input after having cleared up the small details on the other.
Keep your fingers crossed.
I took out the DisplayArray after the first LoadArray call, and left the DisplayArray at the end of the LoadArray function. Seems to work ok.
-
>Ice tea it is, sweet tea of course.
Sweet tea is the best.
Have fun cleaning up the details ... and ... yes a little sleep will be nice about now.
-
infinite loop
when I sort, it misses one of the numbers
0. -22.0
1. -13.5
2. 4.0
3. 8.0
4. 8.0
5. 8.0
6. 21.0
7. 21.0
8. 21.0
9. 21.0
10. 61.0
11. 61.0
12. 21.0
13. 67.1
see number 12? why is that near the bottom?
-
I input:
2, 1, and 3, and it exhibits the same problem ... will not sort. Looks like a bug in the sort function.
-
infinite loop
Thanks for all your help. I will work more on it tomorrow before class and after the kids are off to school.
Get some sleep!
-
I don't know what kind of sort you are using. The only one I know is the bubble sort. If you can use the bubble sort, I think this will work:
Code:
void Sort(float list[],
int length)
{
float temp;
int passCount;
int searchIndex;
for(passCount = 0; passCount<length-1; passCount++)
{
for(searchIndex=passCount+1; searchIndex<length;searchIndex++)
{
if(list[searchIndex] < list[passCount])
{
temp = list[passCount];
list[passCount] = list[searchIndex];
list[searchIndex] = temp;
}
}
}
sorted = true;
DisplayArray(list, length);
}
Also, there is a built in quicksort in c++. You may not be allowed to use this. It's callled qsort.
Signing off til tomorrow afternoon.
-
infinite loop
That sort worked perfectly! I am having a little difficulty with the file input but should be able to work that out.
thanks again for all your help!