import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class selsort {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String nil= JOptionPane.showInputDialog(null,"masukan Nilai Yang Ingin Di urutkan");
String [] t=nil.split(",") ;
int []b=new int[t.length];
for (int k = 0; k < t.length; k++) {
b[k]=Integer.parseInt(t[k]);
}
for(int k=0; k<b.length; k++){
int index_of_min = k;
for(int y=k; y<b.length; y++){
if(b[index_of_min]>b[y])
index_of_min = y;
}
int temp = b[k];
b[k] = b[index_of_min];
b[index_of_min] = temp;
}
for (int k = 0; k < b.length; k++) {
}
String c="";
for (int k = 0; k < b.length; k++) {
if(k==b.length-1)
c +=""+b[k];
else
c+=""+b[k]+",";
}
System.out.print(nil+" hasil pengurutan nya adalah "+c+"\n");
}
}
Posted by 12.54 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar