P1012 and p1012
Description
There are n integers (n ≤ 20) and join them into a row to form a maximum of multiple integers.
For example, when n = 3, the maximum integer 13,312,343 joined by the three integers is 34331213.
For example, when n = 4, the maximum integer of the 4 integers 7, 13, and 4,246 is 7424613.
Input/Output Format
Input Format:
The first line is a positive integer n.
The second row contains n positive integers.
Output Format:
A positive integer that represents the largest integer.
Input and Output sample
Input example #1:
313 312 343
Output sample #1:
34331213
1 # include <iostream> 2 # include <cstdio> 3 # include <cmath> 4 # include <algorithm> 5 using namespace std; 6 string a [50]; 7 int comp (string a, string B) 8 {9 return a + B> B + a; 10 11} 12 int main () 13 {14 int n; 15 scanf ("% d", & n); 16 for (int I = 1; I <= n; I ++) 17 {18 cin> a [I]; 19} 20 sort (a + 1, a + n + 1, comp); 21 for (int I = 1; I <= n; I ++) 22 cout <a [I]; 23 return 0; 24}