Created
May 12, 2015 13:30
-
-
Save nifrasismail/859a16cfe79ca4707356 to your computer and use it in GitHub Desktop.
Bubble_Sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Bubble_Sort { | |
int[] A; | |
int length; | |
public void read(){ | |
int[] B = {48,25,36,95,96,32,31,32}; | |
A = B; | |
length = A.length; | |
} | |
public void sort(){ | |
for (int i = 0; i < A.length-1; i++) { | |
for (int j = 0; j < A.length-1-i; j++) { | |
if(A[j] > A[j+1]){ | |
int temp = A[j]; | |
A[j] = A[j+1]; | |
A[j+1] = temp; | |
} | |
} | |
} | |
} | |
public void print(){ | |
for (int i = 0; i < A.length; i++) { | |
System.out.print(A[i] + " "); | |
} | |
} | |
public static void main(String[] args){ | |
Bubble_Sort B = new Bubble_Sort(); | |
B.read(); | |
B.sort(); | |
B.print(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment