import java.util.Scanner;
public class BubbleInt {
public static void main(String [] args){
Scanner sc1 = new Scanner(System.in);
System.out.println("Please enter the total amount of number:);
int n = sc1.nextInt();
int [] missing = new int [n];
System.out.println("Please enter your numbers:");
for(int i=0; i<n; i++) {
missing[i] = sc1.nextInt();
}
//Sorting from largest to smallest
int temp = 0;
for(int i =0; i<missing.length; i++) {
for(int j =0; j<missing-1; j++) {
if(missing[i] > missing [j+1] {
temp = missing[j+1];
missing[j+1] = missing[i];
missing[i] = temp;
}
}
}
//Displaying
for(int i = 0; i<missing.length; i++) {
System.out.println(missing[i] + " ");
}
}
}
I want to sort an array from largest to smallest which the above code does perfectly but I want to check if there are two integers of the same number of digits. For example if I inputted 77,23,5,1,7,101 the output should be 101 23 77 1 5 7, since 1,5,7 and 23, 77 are of the same number of digits they are reversed.How could i check the elements are of the same length and reverse only them.