Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CPP/Data Structure/bubbleshort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream.h>
#include<conio.h>
void bubble_sorting(int [],int);
void main()
{
int a[50];
int n;
cout<<"enter how many numbers you will be sort";
cin>>n;
cout<<"enter the values\n";
for(int i=0;i<n;i++)
cin>>a[i];
bubble_sorting(a,n);
double b[5]={5.8,6.8,9.3,2.6,4.5};
bubble_sorting(b,n);
cout<<"the sorted array is:-\n ";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
getch();
}

template <class x> void bubble_sorting(x *a,int size)
{
int round,i;
x temp;
for(round=0;round<size;round++)
for(i=0;i<(size-1)-round;i++)
if(a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}