From 158370669b24142a71ce7778b46f5a054cafed8a Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Sun, 26 Dec 2021 02:42:20 +0200 Subject: Add solutions Example solutions to task4+5 --- pract_SI/Pract. 08/Stringstream/task5.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pract_SI/Pract. 08/Stringstream/task5.cpp (limited to 'pract_SI/Pract. 08/Stringstream/task5.cpp') 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 +#include +#include +#include +#include + +int main() +{ + std::string line, word; + std::set 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::iterator it = words.begin(); it != --words.end(); ++it) + { + std::cout << *it << ", "; + } + } + + std::cout << *(--words.end()); + return 0; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d