/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author HP
*/
public class SelectionSort {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int[] data={-5,-8,-11,0,34,1,1,6,9,22,15};
int i,j,tampung,pos;
System.out.println(” Sorting (SELECTION) Oleh :”);
System.out.println(” NAMA : ANGGA ARI WIJAYA”);
System.out.println(” N.I.M : 102410101070″+”\n”);
System.out.println(” Data Sebelum sorting “);
for(i=0;i<data.length;i++){
System.out.print(data[i]+" ");
}
System.out.println("");
for(i=0;i<data.length-1;i++){
pos=i;
for(j=i+1;j<data.length;j++){
if(data[j]<data[pos]){
pos=j;
}
}
if(pos!=i){
tampung=data[pos];
data[pos]=data[i];
data[i]=tampung;
}
}
System.out.println(" Data Setelah sorting");
for(i=0;i<data.length;i++){
System.out.print(data[i]+" ");
}
System.out.println("");
}
}