Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <iterator>
- #include <algorithm>
- int main () {
- std::string my_str, Request;
- std::vector<std::string> words;
- std::cin >> Request;
- while (std::cin >> my_str) {
- words.push_back(my_str);
- }
- if (Request == "ASCENDING") {
- sort(words.begin(), words.end(), std::greater<std::string>());
- } else if (Request == "DESCENDING") {
- sort(words.begin(), words.end(), std::greater<std::string>());
- reverse(words.begin(), words.end());
- }
- for (auto c: words) {
- std::cout << c << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement