fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <sstream>
  5.  
  6. using namespace std;
  7.  
  8. string sort (string slowo){
  9. string litery = slowo;
  10.  
  11. for (int i=0; i<litery.length()-1; i++)
  12. for (int j=0; j<litery.length()-1; j++)
  13. if (litery[j]>litery[j+1])
  14. swap(litery[j], litery[j+1]); // (3)
  15.  
  16. return litery;
  17. }
  18.  
  19. int main() {
  20. stringstream wordlist("hello\ndog\ncat\nmouse\n");
  21. vector<string> words;
  22.  
  23. while (!wordlist.eof()){ // (4)
  24. bool ok = true;
  25. string word;
  26. getline(wordlist,word);
  27. string something = "something";
  28. string sorted = sort(something);
  29.  
  30. if (ok){
  31. cout<<word<<endl; // (1)
  32. words.push_back(word);
  33. }
  34. }
  35.  
  36. for (int i = 0; i<words.size(); i++){
  37. cout<<words[i]<<endl; // (2)
  38. }
  39. }
  40.  
  41.  
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
hello
dog
cat
mouse

hello
dog
cat
mouse