// easy way to do it is to copy words into a vector. // use unique, then copy then back // there are lots of alternatives #include #include using namespace std; int main() { string word; vector words; while (cin >> word) words.push_back(word); vector::iterator start = words.begin(); vector::iterator stop = unique(start, words.end()); while (start != stop) { cout << *start << " "; ++start; } return 0; }