#include <iostream>
#include <iomanip>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
template <class T>
void s_sort(T a[],int n)
{
int i,j,t;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(a[j]<a[i])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
int main()
{
int a[100],i,n;
cout<<"Masukan jumlah elemen : ";
cin>>n;
cout<<"Masukan elemen - elemen tersebut :";
for(i=0;i<n;i++)
{
cout<<"\n Enter : ";
cin>>a[i];
}
s_sort(a,n);
cout<<"Setelah di sorting :";
for(i=0;i<n;i++)
{
cout<<a[i]<<" , ";
}
return 0;
}
Tidak ada komentar:
Posting Komentar