fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. bool compare_alphabetical(const string& lhs, const string &rhs)
  7. {
  8. return lhs < rhs;
  9. }
  10.  
  11. int main()
  12. {
  13. vector<string> names;
  14. for (string name; getline(cin, name); names.push_back(name));
  15.  
  16. sort(names.begin(), names.end(), &compare_alphabetical);
  17.  
  18. cout << "Alphabetische Liste:\n";
  19. for(auto const &name : names)
  20. cout << name << '\n';
  21. }
Success #stdin #stdout 0s 3480KB
stdin
Hans Gruber
HAL 9000
Vigo the Carpathian
Biff Tannen
Grand Moff Tarkin
Leatherface
T-1000
KHAAAAAAN!!!
Dr. Evil
Ming the Merciless
Freddy Krueger
Joker
stdout
Alphabetische Liste:
Biff Tannen
Dr. Evil
Freddy Krueger
Grand Moff Tarkin
HAL 9000
Hans Gruber
Joker
KHAAAAAAN!!!
Leatherface
Ming the Merciless
T-1000
Vigo the Carpathian