#include #include using namespace std; int main() { string line, alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; size_t i; for ( ; getline( cin, line ); ) { for ( ;; ) { // scan words off line string::size_type posn = line.find_first_of( alpha );// find position of 1st alphabetic character if ( posn == string::npos ) break; // any characters left ? line = line.substr( posn ); // remove leading whitespace posn = line.find_first_not_of( alpha ); // find position of 1st non-alphabetic character if ( posn != string::npos ) { cout << line.substr( 0, posn ) << endl; // extract word from start of line line = line.substr( posn ); // delete word from line } else { cout << line << endl; // extract word from start of line line = ""; } } // for } // for }