Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Bubble Sort Java
//Aneesh Pradeeo 27/1/2020 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int arr[] ={3,60,35,2,45,320,5}; System.out.println("Before Bubble Sort"); for(int i=0; i < arr.length; i++){ System.out.print(arr[i] + " "); } System.out.println(); int n = arr.length; int temp = 0; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(arr[j-1] > arr[j]){ //swap elements temp = arr[j-1]; arr[j-1] = arr[j]; arr[j] = temp; }} System.out.println("After Bubble Sort"); for(i=0; i < arr.length; i++){ System.out.print(arr[i] + " "); } System.out.println(); } }}
run
|
edit
|
history
|
help
0
Increment
bit left 2
Геттеры и сеттеры для класса Dog
thư viện
Majors
contoh 43
Stack implementation
decToBin
Java consecutive repeated cha
Fibonacci