diff --git a/UniversalOJ/9/9.cpp b/UniversalOJ/9/9.cpp new file mode 100644 index 00000000..5d21e18c --- /dev/null +++ b/UniversalOJ/9/9.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + int n; + + cin >> n; + + std::vector v(n); + + for (auto& s : v) cin >> s; + + std::sort(v.begin(), v.end(), [&](const std::string& lhs, const std::string& rhs) -> bool { + return lhs.size() == rhs.size() ? lhs < rhs : lhs.size() < rhs.size(); + }); + + for (auto& s : v) cout << s << endl; + + return 0; +}