Bubble Sort

Posted: October 13, 2010 in Algoritma & Struktur Data
Tags:

#include
#include
#include
main()
{
int bil[4]={6,8,3,2};
int temp;
cout<<"Data Sebelum diurutkan : "<<endl;
for(int i=0;i<4;i++)
cout<<setw(3)<<bil[i];
//bubble sort
for(int j=0;j<3;j++)
for(int k=0;k bil[k+1])
{
temp=bil[k];
bil[k]=bil[k+1];
bil[k+1]=temp;
}
}
cout<<endl;
cout<<"Data Setelah Diurutkan : "<<endl;
for(int m=0;m<4;m++)
cout<<setw(3)<<bil[m];
cout<<endl;
cout<<"\t\t\t\tOnet Was Here";
getch();
}

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