Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Pertemuan2;
- public class nomor3 {
- public static void main(String[] args) {
- System.out.println("3,7,8,1,10");
- int[] A = {3,7,8,1,10};
- int min, temp, index = 0;
- for (int i = 0; i < (A.length - 1); i++) {
- min = A[i];
- for (int j = (i + 1); j < A.length; j++) {
- if (A[j] < min) {
- min = A[j];
- index = j;
- }
- }
- temp = A[i];
- A[i] = min;
- A[index] = temp;
- }
- for (int i = 0; i < A.length; i++) {
- System.out.println(A[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement