NIH CONTOH SEDERHANA SORTING ARRAY.....
Silahkan... kalo ada yang maw menambahkan boleh share kok
terima kasih ^_^
#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],i,n,j,temp;
clrscr();
cout<<"Enter the value of n:";
cin>>n;
cout<<"\nEnter the values:\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"Sorted array:\n";
for(i=0;i<n;i++)
{
cout<<a[i]<<"\n";
}
getch();
}
No comments:
Post a Comment