Program :
import java.io.*;
class urut
{
public static void main(String[]args)throws Exception
{
DataInputStream key=new
DataInputStream(System.in);
int[]data;
String st="";
int in=0,m=0;
{
System.out.println("------------------------------------");
System.out.println("Renza Bin Harnata");
System.out.println("06.2009.1.05156");
System.out.println("------------------------------------");
System.out.println("\n")
;
System.out.print("Masukkan
jumlah data yang diinputkan : ");
in=Integer.parseInt(key.readLine());
{
data=new
int[in];
for(int
i=0;i<data.length;i++)
{
{
System.out.print("inpukan
bil. ke-"+(i+1)+" : ");
st=key.readLine();
{
m=Integer.parseInt(st);
if(m<0)
System.out.println(st+"
Tidak boleh negatif\n"+
"Ulangi
kembali pengisian");
else
data[i]=m;
}
System.out.print("\nData
urut : ");
int
bantu=0;
for (int
i=0;i<data.length;i++)
{
for
(int j=i+1;j<data.length;j++)
{
if
(data[i]>data[j])
{
bantu=data[j];
data[j]=data[i];
data[i]=bantu;
}
}
System.out.print("
" +data[i] + " ");
}
}
}
}
}
Tidak ada komentar:
Posting Komentar