Contoh Program java Ascending

COPY PASTE aj gan……

mensorting bilangan kecil sampai bilangan besar…

Gan saya mengerjakan program ini pas praktikum Algoritma,program ini menggunakan bahasa Java,ada sedikit bantuan dari teman saya sich….

saya upload program ini untuk berbagi bersama,para praktikan tinggal Copy paste aja

beri nama “penarray”


import java.io.*;
class penarray
{
public static void main(String[] args) throws Exception
{
DataInputStream tm = new DataInputStream (System.in);
System.out.println("==============================================");
System.out.println("Nama     : IRZIQ UHSI AMDIKEN");
System.out.println("NPM        : 06.2009.1.04802");
System.out.println("==============================================");
System.out.println("");
System.out.print("Masukkan jumlah kata yang diinputkan    : ");

int tampung;
int jml = Integer.parseInt(tm.readLine());
int [] data = new int[jml];

System.out.println("");
for (int i=0; i<jml ;i++ )
{
System.out.print("data ke - "+(i+1)+" : ");
data[i] = Integer.parseInt(tm.readLine());
}

for (int i=0;i<jml;i++){
for(int j=1;j<(jml-i);j++){
if (data[j-1]>data[j]){
tampung = data[j-1];
data[j-1] = data[j];
data[j] = tampung;
}
}
}

for (int k=0;k<jml ;k++ )
{

System.out.println(data[k]);

}

}
}

ini gan hasilnya…… monggo…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s