Horje
c++ code for insertion sort Code Example
c++ code for insertion sort
#include<bits/stdc++.h>

using namespace std;

int main()
{
    //insertion sort
    int a[5] = {1,56,94,12,31};
    //if(n>1)
 int i,j;
 for(i=0;i<5-1;i++)
 {
     for(j=i+1;j>0;j--)
     {
         if(a[j]>=a[j-1])
         {
             break;
         }
         swap(a[j],a[j-1]);
     }
 }
 for(i=0;i<5;i++)
 {
     cout<<a[i]<<" ";
 }
 return 0;
}




Cpp

Related
undefined reference to `pthread_create' c++ Code Example undefined reference to `pthread_create' c++ Code Example
doubly linked list c++ code Code Example doubly linked list c++ code Code Example
create random vectors c++ Code Example create random vectors c++ Code Example
c++ string erase all occurrences Code Example c++ string erase all occurrences Code Example
for loop with array c++ Code Example for loop with array c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8