Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <map>
- using namespace std;
- int main() {
- string line, word;
- getline(cin, line);
- istringstream ss(line);
- vector<pair<string, int>> words;
- while (ss >> word) {
- for (int i = 0; i < word.length(); i++) {
- word[i] = tolower(word[i]);
- }
- bool isword = false;
- for (int i = 0; i < words.size(); ++i) {
- if (words[i].first == word) {
- words[i].second++;
- isword = true;
- break;
- }
- }
- if (!isword) {
- words.push_back(make_pair(word, 1));
- }
- }
- vector<string> output;
- for (int i = 0; i < words.size(); i++) {
- if (words[i].second % 2 == 1) {
- output.push_back(words[i].first);
- }
- }
- for (int i = 0; i < output.size(); i++) {
- cout << output[i];
- if (i < output.size() - 1) {
- cout << ", ";
- }
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement