As you could understand from the title, I'm really a novice in this programming environment. I'd like to ask you for help: I need to read a file like:
These data are one above the other one. So we have 11 columns (11 characters plus newline) and 239 rows. In the original file they are all sorted randomly. I should sort them in ascending order. At the end, it would be nice of course to visualize the output. So far, I have done the first step, I'm reading the file "char by char". But I can't proceed further; my knowledge doesn't permit me that. I would be really glad if someone could help me. I really need this stuff.
I tried a bit by myself, but I don't know how to proceed. For example, once the data is ridden with a class called "readfile", how can i store it in another class called "storefile"? and then how to take the array just created and then sort it in ascending order with another class called "sortfile"?
Is this a good way to proceed? can anybody help me please?
i have an algorithm, don't load the whole file into your program, just load it one value at a time, you're gonna need a function that eases random access to the file.
store the value in a vector or something you're comfort with. Algorithm:
1- find the largest value in the file, store a copy of it in an object cur_largest.
2- find next_largest, the value that is bigger than all except cur_largest.
3- cur_largest = next_largest
4- write cur_largest.
5- repeat steps 2-4 until you finish with the input file.