Comp 272 program 1 Dordal Due: Monday, Jan 29, 2001 You are to read in some words from the console (the amount isn't specified; press CNTL-Z to indicate end-of-file), sort them (your choice of algorithm; one possible algorithm is below), and print them out, one per line. You should *not* read from a named file; use the "standard input". You *will* have to use my version of getline, as the builtin version is broken. Use it to read in lines; you've reached the end of file when either getline reads an empty string or else by checking cin.eof(). void getline(istream & in, string & s) { const int INITIAL_SPACE = 100; s = ""; s.reserve(INITIAL_SPACE); // why is this here? int ch; // why is ch an int?!? while ((ch = in.get()) != '\n' && ch != EOF) s+=ch; } Use the and libraries. Don't use a built-in sort, though. Make sort() a function, too, not just a block of code in main(). Here's an outline of selection sort of a vector A from 0..N-1 (I *think* it works) int i, j, indexofsmallest; for (i=0;i #include #include #include using namespace std; // don't forget this! The sort order should be that built in to the < order of strings; don't do anything special in other words. To submit, email me your .cpp file, and maybe some output. (If you don't send output, you'll be stuck with tests based on my input.) Note that if a program reads from the console you can have it read from a file by firing up a command window and using *redirection*: prog1 < mydata.txt ^causes prog1's "standard input" to be the file, not the console.