Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 08 / Stringstream / task4.cpp
diff options
context:
space:
mode:
1 files changed, 56 insertions, 0 deletions
-rw-r--r--pract_SI/Pract. 08/Stringstream/task4.cpp56
diff --git a/pract_SI/Pract. 08/Stringstream/task4.cpp b/pract_SI/Pract. 08/Stringstream/task4.cpp
new file mode 100644
index 0000000..7b6b185
--- /dev/null
+++ b/pract_SI/Pract. 08/Stringstream/task4.cpp
@@ -0,0 +1,56 @@
+#include <iostream>
+#include <vector>
+#include <string>
+#include <sstream>
+
+int main() {
+ std::string str;
+ std::vector<std::pair<std::string, int>> myVector;
+
+ getline(std::cin, str);
+ std::stringstream ss;
+ ss << str;
+
+ std::string temp;
+ while (ss >> temp) {
+ std::string lowString = "";
+ bool is_exist = false;
+
+ for (size_t i = 0; i < temp.size(); i++)
+ {
+ lowString += tolower(temp[i]);
+ }
+
+ for (size_t i = 0; i < myVector.size(); i++)
+ {
+ if (myVector[i].first == lowString)
+ {
+ myVector[i].second++;
+ is_exist = !is_exist;
+ break;
+ }
+ }
+
+ if (is_exist == false)
+ {
+ myVector.push_back(std::make_pair(lowString, 1));
+ }
+ }
+
+ std::vector<std::string> outVector;
+ for (size_t i = 0; i < myVector.size(); i++)
+ {
+ if (myVector[i].second % 2 == 1)
+ {
+ outVector.push_back(myVector[i].first);
+ }
+ }
+
+ for (size_t i = 0; i < outVector.size() - 1; i++)
+ {
+ std::cout << outVector[i] << ", ";
+ }
+ std::cout << outVector[outVector.size() - 1] << std::endl;
+
+ return 0;
+} \ No newline at end of file