TIME
16.10
Bubble Ascending
assalamu'alaikum
import java.util.Scanner;public class BubbleAscending {public static void main (String [] args){int n, temp2;int temp;int data [] = new int [100];System.out.println("===================================");System.out.println("Mengurutkan Angka Secara Ascending ");System.out.println("===================================");System.out.println();System.out.print("Masukkan jumlah data = " );Scanner input = new Scanner (System.in);n = input.nextInt();System.out.println("------------------------");temp2=n-1;
for(int k=0; kSystem.out.print("Angka ke-" + (k+1) + " = " );
Scanner angka = new Scanner (System.in);int nilai = angka.nextInt();data[k]= nilai;}for(int i=temp2; i>0; i--){for(int j=temp2; j>0; j--){if(data[j] temp=data[j];
data[j]=data[j-1];data[j-1]=temp;}}}System.out.println();System.out.println("Angka setelah diurutkan secara ascending");System.out.println("========================================");for(int i=0; iSystem.out.println("Angka ke-"+(i+1)+" adalah "+data [i]); }}
}Scanner angka = new Scanner (System.in); int nilai = angka.nextInt(); data[k]= nilai; } for(int i=temp2; i>0; i--){ for(int j=temp2; j>0; j--){ if(data[j] temp=data[j]; data[j]=data[j-1];data[j-1]=temp;}}}System.out.println();System.out.println("Angka setelah diurutkan secara ascending");System.out.println("========================================");for(int i=0; iSystem.out.println("Angka ke-"+(i+1)+" adalah "+data [i]); }}
}data[j]=data[j-1]; data[j-1]=temp; } } } System.out.println(); System.out.println("Angka setelah diurutkan secara ascending"); System.out.println("========================================"); for(int i=0; i System.out.println("Angka ke-"+(i+1)+" adalah "+data [i]); } }
}} } }