fork download
  1. #include <set>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string temp;
  10. string mystring;
  11. while(std::getline(std::cin, temp))
  12. mystring += temp + ' ';
  13. temp = "";
  14. set<string> myset;
  15.  
  16. for (unsigned int i = 0; i < mystring.length(); i++)
  17. {
  18. if (isspace(mystring.at(i)))
  19. {
  20. myset.insert(temp);
  21. temp = "";
  22. }
  23. else
  24. {
  25. temp.push_back(mystring.at(i));
  26. }
  27. }
  28. myset.insert(temp);
  29.  
  30. for (set<string>::iterator i = myset.begin(); i != myset.end(); i++)
  31. {
  32. cout << *i << endl;
  33. }
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0.01s 2864KB
stdin
HELLO world this is my
string.
TEST!
stdout
HELLO
TEST!
is
my
string.
this
world