Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 08 / Stringstream / task5.cpp
diff options
context:
space:
mode:
1 files changed, 31 insertions, 0 deletions
-rw-r--r--pract_SI/Pract. 08/Stringstream/task5.cpp31
diff --git a/pract_SI/Pract. 08/Stringstream/task5.cpp b/pract_SI/Pract. 08/Stringstream/task5.cpp
new file mode 100644
index 0000000..b859441
--- /dev/null
+++ b/pract_SI/Pract. 08/Stringstream/task5.cpp
@@ -0,0 +1,31 @@
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <set>
+#include <algorithm>
+
+int main()
+{
+ std::string line, word;
+ std::set<std::string> words;
+
+ getline(std::cin, line);
+ std::istringstream lineStream(line);
+
+ while(lineStream >> word)
+ if(word.size() < 5)
+ {
+ transform(word.begin(), word.end(), word.begin(),[](unsigned char c){ return tolower(c); });
+ words.insert(word);
+ }
+ if (words.size() > 0)
+ {
+ for (std::set<std::string>::iterator it = words.begin(); it != --words.end(); ++it)
+ {
+ std::cout << *it << ", ";
+ }
+ }
+
+ std::cout << *(--words.end());
+ return 0;
+} \ No newline at end of file