Merge pull request #292 from PRITI1999/master

Update Bubble Sort.cpp
This commit is contained in:
Ashwek Swamy
2019-09-20 16:46:44 +05:30
committed by GitHub

View File

@@ -7,7 +7,7 @@ using namespace std;
int main()
{
int n;
short swap_check = 0;
short swap_check = 1;
cout << "Enter the amount of numbers to sort: ";
cin >> n;
vector<int> numbers;
@@ -22,7 +22,7 @@ int main()
}
//Bubble Sorting
for (int i = 0; i < n; i++)
for (int i = 0; (i < n) && (swap_check == 1); i++)
{
swap_check = 0;
for (int j = 0; j < n - 1 - i; j++)
@@ -33,10 +33,6 @@ int main()
swap(numbers[j], numbers[j + 1]);
}
}
if (swap_check == 0)
{
break;
}
}
//Output