Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Pertemuan11;
- import java.util.Scanner;
- /**
- *
- * @author ARI
- */
- public class BubbleShort {
- public static void main(String[] args) {
- Scanner scan= new Scanner(System.in);
- int[] nilai ={scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),};
- for (int i = 0; i < nilai.length; i++) {
- for (int j = 0; j < nilai.length-1; j++) {
- if (nilai[j+1]>nilai[j]) {
- int penampungan = nilai[j];
- nilai [j] = nilai[j+1];
- nilai[j+1] = penampungan;
- }
- }
- }
- for (int i = 0; i < nilai.length; i++) {
- System.out.print(nilai[i]+" , ");
- }
- }
- }
Add Comment
Please, Sign In to add comment