Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {int a[30],n,i,j,x;
- cin>>n;
- for (i=1;i<=n;i++)
- cin>>a[i];
- for(i=2;i<=n;i++){
- x=a[i];
- j=i-1;
- while ((j>0)&&(x<a[j])) { a[j+1]=a[j];
- j=j-1;}
- a[j+1]=x;}
- for (int i=1;i<=n;i++)
- cout<<a[i]<<" ";
- getch();
- }
Add Comment
Please, Sign In to add comment