Guest User

Untitled

a guest
Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. package Pertemuan11;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6. *
  7. * @author ARI
  8. */
  9. public class BubbleShort {
  10. public static void main(String[] args) {
  11. Scanner scan= new Scanner(System.in);
  12. int[] nilai ={scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),};
  13. for (int i = 0; i < nilai.length; i++) {
  14. for (int j = 0; j < nilai.length-1; j++) {
  15. if (nilai[j+1]>nilai[j]) {
  16. int penampungan = nilai[j];
  17. nilai [j] = nilai[j+1];
  18. nilai[j+1] = penampungan;
  19. }
  20.  
  21. }
  22.  
  23. }
  24. for (int i = 0; i < nilai.length; i++) {
  25. System.out.print(nilai[i]+" , ");
  26.  
  27. }
  28.  
  29.  
  30.  
  31. }
  32. }
Add Comment
Please, Sign In to add comment