Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- #include <stack>
- #include <string>
- #include <vector>
- #include <sstream>
- #include <list>
- #include <algorithm>
- using namespace std;
- char tolower_char(char c)
- {
- return tolower(c);
- }
- int main()
- {
- string buffer;
- getline(cin, buffer);
- istringstream istr(buffer);
- string word;
- list< pair<string, size_t> > words;
- while(istr >> word)
- {
- transform(word.begin(), word.end(), word.begin(), tolower_char);
- bool found = false;
- for(auto & elem : words)
- {
- if(elem.first == word)
- {
- elem.second++;
- found = true;
- break;
- }
- }
- if(!found)
- words.push_back( pair<string, size_t>(word, 1) );
- }
- bool firstWord = true;
- for(auto item : words)
- {
- if(item.second %2 )
- {
- if(!firstWord)
- cout << ", ";
- else
- firstWord = false;
- cout << item.first;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement