Title Description
A.D. 20XX years x months x days, V8 and his small partners again early AK (all kill), good V8 in order not to hurt the hearts of other Konjac Konjac, even if AK did not leave early, but because the computer was his two great God teammates to play Gobang (team game Three people a computer), V8 can only a person bored in the draft paper Doodle, when V8 because of miss excessive painting down someone's head, frightened V8 immediately wrote three numbers, 3,2,3, at this time, the wit V8 suddenly found: The three numbers to spell up the maximum is 332! And not 233!!!. The boring V8 wrote down two numbers, 97, 98, and V8 found that the maximum was 9897 instead of 9798. Now the boring V8 wrote n numbers, V8 want to know what the maximum value of the N-numbers to spell up.
Input
Multiple sets of data, please process to the end of the file. The first row of each group of data is a number n (1<=n<=10^5), the second row n digit AI (0<=ai<=10^8).
Output
Each set of data is output in one row, indicating the maximum value it has to spell.
--Text
For people who are lazy with the sort function,
This problem is how to output the comparison results, tried C string is not very convenient, or a C + + string is better
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespaceStd;typedefLong LongLL;strings[100001];BOOLcmpstringAstringb) { stringS1 = a + B,s2 = B +A; return(S1 >s2);}intMain () {intN; while(SCANF ("%d", &n)! =EOF) { inti; for(i=0; i<n;i++) {cin>>S[i]; } sort (S,s+n,cmp); for(i=0; i<n;i++) {cout<<S[i]; } printf ("\ n"); } return 0;}
Xidianoj 1088 AK after V8