Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- bool cmpLess(string a, string b) {
- return a < b;
- }
- bool cmpMore(string a, string b) {
- return a > b;
- }
- int main() {
- string order, current;
- cin >> order;
- vector<string> toSort;
- while (getline(cin, current)) {
- toSort.push_back(current);
- }
- if (order == "ASCENDING") {
- sort(toSort.begin(), toSort.end(), cmpLess);
- } else {
- sort(toSort.begin(), toSort.end(), cmpMore);
- }
- for (int i = 0; i < toSort.size(); ++i) {
- cout << toSort[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement