#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();
}
#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
Reviewed by Shobhit Goel
on
September 11, 2015
Rating:
No comments:
Post a Comment