41 lines
871 B
Java
41 lines
871 B
Java
import java.util.Scanner;
|
|
|
|
public class LabProgram {
|
|
|
|
/* Define your method here */
|
|
public static void sortArray(int[] myArr, int arrSize){
|
|
int temp;
|
|
int flag;
|
|
|
|
for(int i = 0; i < arrSize-1;i++){
|
|
flag = 0;
|
|
for(int j = 0; j < arrSize-1; j++){
|
|
if (myArr[j] > myArr[j+1]){
|
|
temp = myArr[j];
|
|
myArr[j] = myArr[j+1];
|
|
myArr[j+1] = temp;
|
|
flag = 1;
|
|
}
|
|
}
|
|
if (flag == 0){
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
public static void main(String[] args) {
|
|
Scanner scnr = new Scanner(System.in);
|
|
int[] myInts = new int[20];
|
|
int myIntsLength = scnr.nextInt();
|
|
for (int i=0;i < myIntsLength;i++){
|
|
myInts[i] = scnr.nextInt();
|
|
}
|
|
|
|
sortArray(myInts, myIntsLength);
|
|
|
|
for(int i=0; i<myIntsLength; i++){
|
|
System.out.print(myInts[i] + " ");
|
|
}
|
|
System.out.println();
|
|
}
|
|
}
|