Question: enter a positive integer array, splice all the numbers in the array into a number, and print the smallest of all the numbers that can be spliced.
For example, if the input array is {3, 32,321}, the minimum number 321323 that can be arranged for the three numbers will be printed.
The two numbers M and N can be spliced into numbers Mn AND nm. If Mn <nm, the Mn is printed, that is, M is placed before n. We define that M is less than N at this time, that is, the function pointer that customizes the qsort sorting.
The number to be spliced in this question may be out of the expression range and must be addressed in large numbers.
Int compare (const void * strnumber1, const void * strnumber2); // int integers can be expressed in decimal notation with a maximum of 10 const int g_maxnumberlength = 10; char * g_strcombine1 = new char [g_maxnumberlength * 2 + 1]; char * g_strcombine2 = new char [g_maxnumberlength * 2 + 1]; void printminnumber (int * numbers, int length) {If (numbers = NULL | length <= 0) return; char ** strnumbers = (char **) (new int [length]); for (INT I = 0; I <length; ++ I) {strnumbers [I] = new char [g_maxnumberlength + 1]; sprintf (strnumbers [I], "% d", numbers [I]);} qsort (strnumbers, length, sizeof (char *),Compare); For (INT I = 0; I <length; ++ I) printf ("% s", strnumbers [I]); printf ("\ n "); for (INT I = 0; I <length; ++ I) Delete [] strnumbers [I]; Delete [] strnumbers ;} // If [strnumber1] [strnumber2]> [strnumber2] [strnumber1], the return value is greater than 0 // If [strnumber1] [strnumber2] = [strnumber2] [strnumber1], return value is equal to 0 // If [strnumber1] [strnumber2] <[strnumber2] [strnumber1], return value is less than 0int compare (const void * strnumber1, const void * strnumber2) {// [strnumber1] [strnumber2] strcpy (g_strcombine1, * (const char **) strnumber1); strcat (g_strcombine1, * (const char **) strnumber2 ); // [strnumber2] [strnumber1] strcpy (g_strcombine2, * (const char **) strnumber2); strcat (g_strcombine2, * (const char **) strnumber1 ); return strcmp (g_strcombine1, g_strcombine2 );}