Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test{
- static int MAX = 6;
- public void BubbleSort(int A[]){
- int i,j, current;
- for(i=0; i<MAX;i++){
- for (j=0; j<MAX-1; j++){
- if(A[j]>A[j+1]){
- current = A[j];
- A[j] = A[j+1];
- A[j+1] = current;
- }
- }
- }
- }
- public static void main(String[] args){
- int num[]={39,54,28,69,17,1};
- System.out.println("Original: ");
- for(int i = 0; i<MAX; i++){
- if(i !=MAX-1){
- System.out.println(num[i] + ",");
- }else{
- System.out.println(num[i]);
- }
- }
- System.out.println("");
- Test b1 = new Test();
- b1.BubbleSort(num);
- System.out.println("Sorted: ");
- for(int i = 0; i<MAX; i++){
- if(i !=MAX-1){
- System.out.println(num[i] + ",");
- }else{
- System.out.println(num[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement