#include<iostream.h> #include<conio.h> void main() { clrscr(); int a[100],i,n,p,k,min,loc,temp; cout<<"\n***PROGRAM SELECTION SORT*** \n\n"; cout<<"Masukkan Elemen ="; cin>>n; cout<<"\nElementnya=\n"; for(i=1;i<=n;i++) { cin>>a[i]; } for(p=1;p<=n-1;p++) { min=a[p]; loc=p; for(k=p+1;k<=n;k++) { if(min>a[k]) { min=a[k]; loc=k; } } temp=a[p]; a[p]=a[loc]; a[loc]=temp; } cout<<"\nSetelah diSorting : \n"; for(i=1;i<=n;i++) { cout<<a[i]<<endl; } getch(); }
10:00 PM |
Category: |
0
comments
Comments (0)