Buble Short 1
Buble Sort 1
Contoh Progam Buble Sort
dengan satu inpitan
aplikasi menggunakan Borland C++
Jika belum punya borland C++ bisa download di menu Aplikasi
#include <iostream.h>
#include <conio.h>
void main()
{
int angka[20];
int temp,jml;
cout<<"masukan jumlah angka: "; cin>>jml;
for ( int a = 1; a<=jml; a++)
{
cout<<"masukan angka ke-"<<a<<" :";
cin>>angka[a];
}
clrscr();
cout<<"================================================"<<endl;
cout<<"Pengaturan dengan Duble sort"<<endl;
cout<<"================================================"<<endl;
cout<<"Data Sebelum shoting"<<endl;
for (int a=1; a<=jml;a++)
{
cout<<" "<<angka[a];
}
cout<<endl;
//double
for (int a =1; a <=jml; a++)
{
for(int j = 1; j<=jml-1; j++)
{
if (angka[j]<= angka[j+1])
{
temp = angka [j];
angka [j] = angka [j+1];
angka [j+1] = temp ;
}
}
}
cout << "data setelah shorting: "<<endl;
for (int i=1; i<= jml; i++)
{
cout<<" "<<angka[i];
}
getch();
}
#include <conio.h>
void main()
{
int angka[20];
int temp,jml;
cout<<"masukan jumlah angka: "; cin>>jml;
for ( int a = 1; a<=jml; a++)
{
cout<<"masukan angka ke-"<<a<<" :";
cin>>angka[a];
}
clrscr();
cout<<"================================================"<<endl;
cout<<"Pengaturan dengan Duble sort"<<endl;
cout<<"================================================"<<endl;
cout<<"Data Sebelum shoting"<<endl;
for (int a=1; a<=jml;a++)
{
cout<<" "<<angka[a];
}
cout<<endl;
//double
for (int a =1; a <=jml; a++)
{
for(int j = 1; j<=jml-1; j++)
{
if (angka[j]<= angka[j+1])
{
temp = angka [j];
angka [j] = angka [j+1];
angka [j+1] = temp ;
}
}
}
cout << "data setelah shorting: "<<endl;
for (int i=1; i<= jml; i++)
{
cout<<" "<<angka[i];
}
getch();
}
No comments :
Post a Comment