Common class test {
Public static void main(String[] args) {
int[]array = new int[ 1000];
for(int I = 0; I< 1000; i++) {
array[I]= I;
}
boolean loopFlag = true
while(loopFlag) {
System.out.println ("Please enter characters:");
Scanner sc = new scanner (system. in);
string result = sc . nextline();
if ("A "。 EqualsIgnoreCase) (
Array = sort (array, result);
Print (array);
} else if ("B "。 EqualsIgnoreCase) (
Array = sort (array, result);
Print (array);
} else if ("C "。 EqualsIgnoreCase) (
Array = sort (array, result);
Print (array);
} Otherwise {
System.out.println ("The content you entered is illegal, please re-enter ...");
}
System.out.println ("press Y/y to continue, press N/n to exit?" );
Scanner scanner = new scanner (system. in);
string input = scanner . nextline();
if ("N "。 equalsIgnoreCase(input)) {
loopFlag = false
System.out.println ("Exit successful!" );
}
}
}
/**
* @param a
* @param b
* @param type comparison type
* @ If a>b returns true.
*/
Common static boolean comparison (int a, int b, String type) {
Int percentile = a/100;
int tenDigitA = a % 100/ 10;
int single digita = a % 100% 10;
Int percentile = b/100;
int tenDigitB = b % 100/ 10;
int singleDigitB = b % 100% 10;
if("B "。 equalsIgnoreCase(type)) {
//Ten places > Unit > Third place from the right
if(tenDigitA & gt; tenDigitB) {
Return true
} else if(tenDigitA & lt; tenDigitB){
Returns false
} Otherwise {
if(singleDigitA & gt; singleDigitB) {
Return true
} else if(singleDigitA & lt; singleDigitB){
Returns false
} Otherwise {
If (hundred digits & gt hundred digits B) {
Return true
} else if (best & lt hundredth B){
Returns false
} Otherwise {
// a and B are equal, and can return true/false, which is basically not the case.
Return true
}
}
}
} else if ("C "。 equalsIgnoreCase(type)) {
//bits > hundreds > decimal
if(singleDigitA & gt; singleDigitB) {
Return true
} else if(singleDigitA & lt; singleDigitB){
Returns false
} Otherwise {
If (hundred digits & gt hundred digits B) {
Return true
} else if (best & lt hundredth B){
Returns false
} Otherwise {
if(tenDigitA & gt; tenDigitB) {
Return true
} else if(tenDigitA & lt; tenDigitB){
Returns false
} Otherwise {
//equal, just return true/false, it won't go so far.
Return true
}
}
}
} Otherwise {
//Hundred > Ten > Units
If (hundred digits & gt hundred digits B) {
Return true
} else if (best & lt hundredth B){
Returns false
} Otherwise {
if(tenDigitA & gt; tenDigitB) {
Return true
} else if(tenDigitA & lt; tenDigitB){
Returns false
} Otherwise {
if(singleDigitA & gt; singleDigitB) {
Return true
} else if(singleDigitA & lt; singleDigitB){
Returns false
} Otherwise {
//equal, just return true/false, it won't go so far.
Return true
}
}
}
}
}
/**
*
* @param array sort array
* @param type sort type, passing in strings "a", "b" and "c"
* @ Return
*/
public static int[]sort(int[]array,String type) {
Int length = array.length
for(int I = 0; I < length; i++) {
for(int j = 0; J< length-1; j++) {
If (! compare(array[j],array[j+ 1],type)) {
//If the preceding number is less than the following number, transpose it.
Internal temperature;
temp = array[j];
array[j]= array[j+ 1];
array[j+ 1]= temp;
}
}
}
Returns an array;
}
public static void print(int[]array){
for (int number : array) {
system . out . print(number+" & gt; );
}
system . out . println();
}
}
Species, ~ cm thick, its function is to sterilize, enhance resistance and accelerate germination.