Advertisement
bobo_bobkata

Untitled

Oct 23rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4. #include <sstream>
  5. #include <cmath>
  6. #include <list>
  7.  
  8. std::string getLower(std::string str) {
  9. std::string newString = "";
  10. for (int i = 0; i < str.length(); ++i) {
  11. char current = std::tolower(str.at(i));
  12. newString += current;
  13. }
  14. return newString;
  15. };
  16.  
  17. int main() {
  18. std::string input;
  19. std::getline(std::cin, input);
  20. std::stringstream stringstream(input);
  21. std::string str = "";
  22. std::vector<std::string> vector;
  23. while (stringstream >> str) {
  24. vector.push_back(str);
  25. }
  26. std::vector<std::string> result;
  27. for (int i = 0; i < vector.size(); ++i) {
  28. std::string current = getLower(vector[i]);
  29. vector.erase(vector.begin() + i);
  30. i--;
  31. int countRepeated = 1;
  32. for (int j = i + 1; j < vector.size(); ++j) {
  33. std::string currentString = getLower(vector[j]);
  34. if (current == currentString) {
  35. vector.erase(vector.begin() + j);
  36. j--;
  37. countRepeated++;
  38. }
  39. }
  40. if (countRepeated % 2 != 0) {
  41. result.push_back(current);
  42. }
  43. }
  44. for (int k = 0; k < result.size(); ++k) {
  45. if (k == result.size() - 1) {
  46. std::cout << result[k];
  47. } else {
  48. std::cout << result[k] << ", ";
  49. }
  50. }
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement