casper. Powered by Blogger.

Blog ini bertujuan untuk share ilmu dan pengetahuan. Semua source/aplikasi di blog ini bebas disebar dan mencamtumkan sumber "fandy-alfa.blogspot.com".

RSS

ARRAY SORT

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pbo;

import java.io.IOException;

/**
 *
 * @author Fandy
 */

/*
 *  Nama : Fandy Adam
 *  Stambuk : E1E1 09 053
 *  Tugas Mata Kuliah : PBO
 *  Jurusan : IT
 *
 *  SOAL 6 : ARRAY SORT
 */

public class soal6 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {      
        int x [] = {29, 13, 10, 7, 34, 21, 4, 54, 30};
      
        System.out.println(" Aplikasi Sort Data ");
        System.out.println("====================");
        System.out.print("\nData sebelum dilakukan pengurutan : ");
        for (int i=0; i<x.length; i++) {
            System.out.print(x[i]+" ");
        }
       
        int temp;
        for (int i=0; i<x.length; i++) {
            for(int j=i; j<x.length; j++) {
                if(x[i] > x[j]) {
                    temp = x[i];
                    x[i] = x[j];
                    x[j] = temp;
                }
            }
        }
       
        System.out.print("\nData setelah dilakukan pengurutan : ");
        for (int i=0; i<x.length; i++) {
            System.out.print(x[i]+" ");
        }
    }
}
 
  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment