Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool cmpLess(string a, string b) {
  9. return a < b;
  10. }
  11.  
  12. bool cmpMore(string a, string b) {
  13. return a > b;
  14. }
  15.  
  16. int main() {
  17. string order, current;
  18. cin >> order;
  19. vector<string> toSort;
  20. while (getline(cin, current)) {
  21. toSort.push_back(current);
  22. }
  23. if (order == "ASCENDING") {
  24. sort(toSort.begin(), toSort.end(), cmpLess);
  25. } else {
  26. sort(toSort.begin(), toSort.end(), cmpMore);
  27. }
  28. for (int i = 0; i < toSort.size(); ++i) {
  29. cout << toSort[i] << endl;
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement