Skip to content

Commit

Permalink
Added bubble sort descending.
Browse files Browse the repository at this point in the history
  • Loading branch information
yugantarjain authored Oct 16, 2018
1 parent 01ae12f commit a88eaab
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Sorting/bubble sort/cpp/buubleDesc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
using namespace std;

void bubbleSort(int A[],int n)
{
int i,j;
int temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(A[j]<A[j+1])
{
temp=A[j];
A[j]=A[j+1];
A[j+1]=temp;
}
}
}
}

int main()
{
int n;
cout<<"Enter the size of the array\n";
cin>>n;
int a[n];
cout<<"Enter the element\n";
for(int i=0;i<n;i++)
{
cin>>a[i];
}
bubbleSort(a,n);
cout<<"The Sorted array is :-";
for(int i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
return 0;
}

0 comments on commit a88eaab

Please sign in to comment.