/**
* @Version 1.0.0
* enter an array of positive integers to stitch together all the numbers in the array into a number,
* The smallest one that prints all the numbers that can be spliced out. For example, enter{3,32,321,4}, the minimum number to print is
* 321323
*
* is actually a sort of, but the comparison of the size of the way and the value is different
* Here's a bubble sort of way
*/
Public classPro33 {
@MyAnswer
Public static voidF(intArray[]) {
for(intI=0;I<array.length-1;i++) {
intbig=0;
for(intj=0;J<array.length-I.;J + +) {
if(Compare(String.valueOf(Array[j]),String.valueOf(Array[big])) >0){
Big=j;
}
}
if(Big!=array.length-i-1){
intTemp=array[big];
Array[big]=array[array.length-i-1];
Array[array.length-i-1]=temp;
}
}
for(intA:array) {
System. out. Print (A +" ");
}
}
@MyAnswer
public static intCompare(String A, String b) {
String left=a+b;
String Right=b+a;
for(intI=0;I<left.length ()-1;i++) {
if(Left.charat (i) >right.charat (i)) {
return1;
}else if(Left.charat (i) <right.charat (i)) {
return-1;
}
}
return0;
}
Public static voidMain(String args []) {
intarray[]=/*{23,345, 121,42,1}*/{3, +,321,4};
Pro33.F(array);
}
}
Enter an array of positive integers, combine all the numbers in the array into a number, and print the smallest of all the numbers that can be stitched together.