Last active
November 5, 2019 08:50
-
-
Save pinglunliao/9fe456995b34e629935f to your computer and use it in GitHub Desktop.
b051: 2. 排列最大值 FYI: https://yunlinsong.blogspot.com/2015/07/blog-post.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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