Hello! so, I'm implementing quicksort and selection sort using vectors.
I have the following code. To run I use redirection. i.e. ./program.out <datafile
But my vector seems to be empty?Code:int main() { int number; vector<int> list; cout << "QuickSort..." << endl; while (cin >> number) { list.push_back(number); } int left = 0; int size = list.size(); int right = size-1; print(list); // testing sort quickSort(list, left, right); print(list); // testing sort cout << "Done" << endl; return 0; }
I've changed the while loop to
That gives me a bad_alloc error though.Code:cin >> number; while (!cin.eof()) { list.push_back(number); cin >> number; }
Any tips? My sorts work with small sets, but I haven't been able to test larger 2000 and above sets yet because of this. :(



LinkBack URL
About LinkBacks


