Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:50
Show Gist options
  • Save pinglunliao/9fe456995b34e629935f to your computer and use it in GitHub Desktop.
Save pinglunliao/9fe456995b34e629935f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool cmp(const string& s1, const string& s2)
{
return (s1 + s2).compare(s2 + s1) > 0;
}
int main()
{
int n;
while(cin >> n)
{
string s[n];
for(int i = 0; i < n; i++)
cin >> s[i];
sort(s, s+n, cmp);
for(int i = 0; i < n; i++)
cout << s[i];
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment