Rabu, 06 Juni 2012

Soure Code Selection Sort Menggunakan Inputan user (javac.swing) :


package Pertemuan5;
import javax.swing.JOptionPane;
/**
 *
 * @author ika
 */
public class Selection {
    public static void main(String[] args){
        int x =Integer.parseInt(JOptionPane.showInputDialog("Masukkan Data"));
          int i, temp, j;
        int[]data=new int[x];
        for(int index=0;index
       data[index]=Integer.parseInt(JOptionPane.showInputDialog("Masukkan angka ke -"+(index+1)));
        System.out.println("Sebelum diurutkan :");
            for(i=0;i
            System.out.print(data[i]+"\t");
            System.out.println("\n");
                for(i=0;i
                    for(j=i+1;j
                        if(data[i]>data[j]){
                            temp = data[i];
                            data[i] = data[j];
                            data[j] = temp;
                        }
                    }
                for(int k=0;k
                    System.out.print(data[k]+"\t");
                        System.out.println();
                    }
                System.out.println("Setelah diurutkan :");
                    for(i=0;i
                    System.out.print(data[i]+"\t");
                }
         }

0 komentar:

Posting Komentar

TOP ENTRY