Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a[5];
- for(int i=0; i<5; i++)
- {
- cin>>a[i];
- }
- for(int j=1; j<5; j++)
- {
- int key=a[j];
- int i=j-1;
- while(i>=0 && a[i]>key)
- {
- a[i+1]=a[i];
- a[i]=key;
- i--;
- }
- }
- for(int i=0; i<5; i++)
- {
- cout<<a[i]<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment