You are viewing a single comment's thread. Return to all comments →
Good solution, but you're style need to medernize :P
#include <vector> #include <iostream> #include <algorithm> #include <iterator> using namespace std; bool string_less_comparision(const string& s1, const string& s2) { if (s1.length() == s2.length()) return s1 < s2; return s1.length() < s2.length(); } int main() { int sz; cin >> sz; vector<string> a(sz); copy_n(istream_iterator<string>(cin), sz, begin(a)); sort(begin(a), end(a), string_less_comparision); copy(begin(a), end(a), ostream_iterator<string>(cout, "\n")); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
Good solution, but you're style need to medernize :P