class urutan
{
public static void main (String[]args)throws Exception
{
System.out.println ("Nama : Ainul Masyayikh");
System.out.println ("NPM : 06.2009.1.04662");
System.out.println ("*******************************");
DataInputStream dis=new DataInputStream (System.in);
System.out.print ("Inputkan Jumlah Data = ");
int j=Integer.parseInt (dis.readLine());
int h,i,t;
int a[] = new int [j];
for (i=0;i<j;i++)
{
System.out.print("Data ke_ "+(i+1)+" : ");
a[i] = Integer.parseInt(dis.readLine());
}
for (h=0;h<(j-1);h++)
{
for (i=(h+1);i<j;i++)
{
if (a[i]<a[h])
{
t = a[h];
a[h] = a[i];
a[i] = t;
}else
{}
}
}
System.out.print ("Data Urut : ");
for (i=0;i<j;i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
}
}
Tidak ada komentar:
Posting Komentar