# include
<iostream.h>
# include
<conio.h>
# include
<iomanip.h>
# include
<stdio.h>
# include
<iostream.h>
main()
{
int a[1];
int x;
int tukar;
int temp;
int i;
clrscr();
cout<<"progam
mengurutkan data yang di inputkan\n";
cout<<"oleh : ISLAHUDIN \n";
cout<<"----------------------------------\n\n";
cout<<"Berapa Data yang Mau di Inputkan :";cin>>x;
for (i=1; i<=x;
i++)
{ cout << "Input Data ke"
<<i<< " : "; cin >> a[i];}
cout <<
"Data sebelum di-sort : ";
for (i=1; i<=x;
i++)
{ cout << endl <<
setw(6) << a[i]; }
tukar=1;
while(tukar==1)
{
tukar=0;
for(i=1;
i<=x-1; i++)
{
if(a[i]<a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
tukar=1;
}
}
}
cout<<"\n\nData setelah di-sort : ";
for(i=1; i<=x;
i++)
{
cout<<setw(6)<<a[i]; }
getch();
}
dan ini lah hasil outputnya:
Sumber: http://islahudin-soft-it.blogspot.com/2013/05/program-c-mengurutkan-data-dari-yang.html
0 komentar:
Posting Komentar