// Phil Ottewell's STL Course - http://www.pottsoft.com/home/stl/stl.htmlx // // Example 1.2 © Phil Ottewell 1997 // // Purpose: // Simple vector and sort demonstration using the STL // ANSI C Headers #include // C++ STL Headers #include #include #include #ifdef _WIN32 using namespace std; #endif int main( int argc, char *argv[] ) { int ival, nitems = 0; vector v; cout << "Enter integers, after each, Z to finish:" << endl; while( cin >> ival, cin.good() ) { v.push_back( ival ); cout.width(6); cout << nitems << ": " << v[nitems++] << endl; } if ( nitems ) { sort( v.begin(), v.end() ); for (vector::const_iterator viter=v.begin(); viter!=v.end(); ++viter) cout << *viter << " "; cout << endl; } return( EXIT_SUCCESS ); }