Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <utility>
- #include <map>
- #include <sstream>
- #include <vector>
- #include <queue>
- using namespace std;
- void makeItLowerCases(string& input)
- {
- if (input[0] >= '0' && input[0] <= '9')
- {
- input = input;
- }
- else
- {
- const int size = input.size();
- for (int i = 0; i < size; i++)
- {
- if (input[i] >= 'A' && input[i] <= 'Z')
- {
- input[i] = input[i] + 32;
- }
- }
- }
- }
- int main()
- {
- string input;
- getline(cin, input);
- istringstream istr(input);
- string word;
- map<string, int> words;
- queue<string> output;
- vector<string> result;
- while (istr >> word)
- {
- makeItLowerCases(word);
- if (words.find(word) == words.end())
- {
- output.push(word);
- }
- words[word]++;
- }
- while (!output.empty())
- {
- string key = output.front();
- if ((words.find(key)->second % 2) != 0)
- {
- result.push_back(key);
- }
- output.pop();
- }
- int counter = 0;
- const int size = result.size();
- for(string elem : result)
- {
- counter++;
- cout << elem;
- if (counter < size)
- {
- cout << ", ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement