There is lots of number games for children. These games is pretty easy-to-play but not so easy-to-make. We'll discuss about a interesting game here. Each player would be given N positive integer. S He can make a big integer by appending those integers after one another. Such as if there is 4 integers as 123, 124,, and the following integers can be made–1231245690, 1241235690, 5612 312490, 9012312456, 9056124123 etc. In fact such integers can is made. But one thing are sure that 9056124123 are the largest possible integer which can be made.
Think that it's very easy-to-find out the the answer but would it is easy for a child who had just got the idea of numb Er?
Input
Each of the input starts with a positive integer N (≤50). In next lines there is N positive integers. Input is terminated by N = 0, which should isn't be processed.
Output
For each of the input set, you had to print the largest possible integer which can is made by appending all the N integ ERs.
Sample Input
4
123 124 56 90
5
123 124 56) 90 9
5
9 9 9) 9 9
0
Output for Sample Input
9056124123
99056124123
99999
Test instructions: the maximum string combination;
1 BOOL cmp (stringstring b)2{3 return a+b > B +A; 4 }
Skill is more strong. Pay attention to the use of similar types of problems;
1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <string>6#include <vector>7#include <algorithm>8 using namespacestd;9 Const intMAXN = -;Ten stringSTR[MAXN]; One BOOLcmpstringAstringb) A { - returnA+b > B +A; - } the intMain () - { - intN; - while(Cin >> N &&N) + { - for(inti =0; I < n; i++) +CIN >>Str[i]; ASort (str, str+N, CMP); at for(inti =0; I < n; i++) -cout <<Str[i]; -cout <<Endl; - } - return 0; -}
View Code
"String sort, tricks!" "UVa 10905-children ' s Game