/* An example C++ program that alphabetically sorts its input lines. */ #include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; int main() { /* Declare an indexable container for strings. */ vector<string> lines; /* While stdin is not EOF, read lines. */ while(cin.good()) { string s; /* Read line */ getline(cin, s); /* Append it into the vector */ lines.push_back(s); } /* Sort the vector */ sort(lines.begin(), lines.end()); /* Output the contents of the vector */ for(unsigned a=0; a<lines.size(); ++a) cout << lines[a] << endl; /* End. The vector will automatically dispose of itself * when it goes out of the scope (denoted by { and }.) */ return 0; }