Social Icons

banner image

SORTING IN DATA STRUCTURE EXAMPLE

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i,j, temp;
int a[20];
cout<<"Enter the size";
cin>>n;
    cout<<"Enter the elements";
for(i=0;i<n;i++)
{
cin>>a[i];
}

for(i=0;i<n;i++)
{
   for(int j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"Content after sorting";
for(i=0;i<n;i++)
{
cout<<a[i];
    }
        getch();
}

SORTING IN DATA STRUCTURE EXAMPLE SORTING IN DATA STRUCTURE EXAMPLE Reviewed by Shobhit Goel on September 11, 2015 Rating: 5

No comments:

Airtel Hackaton 2017

Powered by Blogger.