#include<iostream>
#include<conio.h>
using namespace std;
void display(int b[]);
int main()
{
int a[]={9,5,3,7,4,6,1,2,8,9,4,5,6,2,0},n;
cout<<"Numbers before BUBBLE SORT :\n";
display(a);
cout<<"\nNumber after BUBBLE SORT : \n";
for(int i=0;i<14;i++)
{
for(int j=0;j<14-i;j++)
{
if(a[j]>a[j+1])
{
int t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
display(a);
getch();
return(0);
}
void display(int b[])
{
for(int i=0;i<15;i++)
{
cout<<b[i]<<" ";
}
}
No comments:
Post a Comment