Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- int main()
- {
- clrscr();
- int n,i,j,k,min,loc,temp,a[10];
- cout<<"\nEnter the value for n"<<endl;
- cin>>n;
- cout<<"enter values"<<endl;
- for(i=0;i<n;i++)
- {
- cin>>a[i];
- }
- for(k=0;k<n;k++)
- {
- min=a[k];
- loc=k;
- for(j=k+1;j<n;j++)
- {
- if(min>a[j])
- {
- min=a[j];
- loc=j;
- }
- }
- temp=a[k];
- a[k]=a[loc];
- a[loc]=temp;
- }
- cout<<"\nSelected array:"<<endl;
- for(i=0;i<n;i++)
- cout<<a[i]<<"\t";
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement