| DrolArumil (30) | |||
|
Sorry if this is too newb, but no one in beginner responded to me so ill try here. I am suppose to make a program that reads in data from a text file (integers only) and sorts them as it inserts them into an array of size 10. I did this using an insertion sort, which worked great. But now I am being told that I need the function has to read ALL of the numbers in the text file, not just the first 10, and I am not allowed to store them THEN sort, it has to be sorted as being stored. I cannot figure out how to do this, Any help would be appreciated. This is what I have for sorting first 10
| |||
|
|
|||
| SamuelAdams (320) | |
|
How would you do it if you were doing it on paper, or for example sorting pennies by year, one at a time ? | |
|
|
|
| DrolArumil (30) | |
|
As far as I know, I have to do it one at a time, dont I? can the fstream hold more than more value at a time? also the numbers are arbitrary, they wont necessarily be 1,2,3,4... it could be 2,5,8,12,15... and the way the txt file is laid out is like this 1 2 3 4 so each number is a line | |
|
Last edited on
|
|