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