There are n positive integers (n<=20), which are concatenated into a row to form the largest multi-bit integer.
For example: n=3, 3 integers 13, 312, 343 the maximum concatenated integer is: 34331213
Also such as: n=4, 4 integer 7,13,4,246 concatenated into the largest integer is: 7424613
#include <iostream>#include<string>#include<cstring>#include<algorithm>using namespacestd; stringa[ +]; BOOLCompstringAstringb) {return(A + B > B + a);//give a direct-to-order condition to be met by a before B} intMain () {intN, D =1; CIN>>N; for(inti =0; I < n; i++) Cin>>A[i]; Sort (A, n+A, comp); for(inti =0; I < n; i++) cout<<A[i]; cout<<Endl; }
The definition of the sort self-writable CMP function in STL, the so-called CMP or any other name function, is actually a validator. Is whether the check sequence conforms to the order required by the programmer after the computer has been sorted.
Sort for specific rules