Respuesta :
Answer:
See explaination
Explanation:
// import the necessary package.
import java.util.Scanner;
// declare a class.
public class Labprogram {
// Start the main
public static void main(String[] args) {
// declare the input of scanner class.
Scanner input = new Scanner(System.in);
// input number.
int numb = input.nextInt();
// declare an array.
int[] in_arr = new int[numb];
// start the for loop
for (int b = 0; b < in_arr.length; b++) {
// Assign values to array.
in_arr[b] = input.nextInt();
}
// Call the method.
SortArray(in_arr, numb);
input.close();
}
// Definition of the method.
private static void SortArray(int[] myArr, int arrSize) {
// Declare an array.
int[] S_Array = new int[arrSize];
int temp;
// start the for loop
for (int j = 0; j < myArr.length - 1; j++) {
// start the for loop
for (int i = 0; i < myArr.length - 1; i++) {
// check the condition.
if (myArr[i] > myArr[i + 1]) {
// swap the values.
temp = myArr[i];
myArr[i] = myArr[i + 1];
myArr[i + 1] = temp;
S_Array = myArr;
}
}
}
// declare the object of set builder class.
StringBuilder build = new StringBuilder();
// start the for loop
for (int val : S_Array) {
build.append(val + " ");
}
// Declare variable.
String numb = build.toString();
// Assign value.
System.out.println(numb);
}
}