Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int i,j,p,a[100],swap,n;
- printf("Enter the number=");
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- scanf("%d",&a[i]);
- }
- for(i=1;i<=n-1;i++)
- {
- p=i;
- j=i+1;
- while(j<=n)
- {
- if (a[p]>a[j])
- {
- p=j;
- }
- j++;
- }
- swap=a[i];
- a[i]=a[p];
- a[p]=swap;
- }
- for(i=1;i<=n;i++)
- {
- printf("%d",a[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement