I'm trying to read in data from a file, run bubble sort on it and store the results in a file using C++...how would i do that. I understand bubble sort and I've used it before. Using it to sort to data from a file is the hard part, any help would be appreciated...
Sorting data from file using bubble sort?
by using iosteam and vector headerfiles/library
, u could do very easily.. :p
just read the input file and for every value you reads,
add that to a declared variable vector
( vector is same as an array but simpler).
and when you finished reading the input file,
apply your bubble sort algo to the vector.
(you could also look on the STL for sorting, i guess it
is in the "functional.h")..
after the vector is sorted, just save it and it is done.. :p
hope that helps even though there is
no codes i've presented for you..
i did that in purpose so that it is
you who will actually code
the program for ur problem.. :)
Reply:So read all the data from the file into an array first.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment