formatting source-code for d7af6fdc8c

This commit is contained in:
github-actions
2020-05-29 23:26:30 +00:00
parent edb3d51ec2
commit 7ad1f171c1
176 changed files with 5342 additions and 4288 deletions

View File

@@ -40,7 +40,8 @@ optimized bubble sort algorithm. It's right down there.
#include <iostream>
#include <vector>
int main() {
int main()
{
int n;
bool swap_check = true;
std::cout << "Enter the amount of numbers to sort: ";
@@ -50,16 +51,20 @@ int main() {
int num;
// Input
for (int i = 0; i < n; i++) {
for (int i = 0; i < n; i++)
{
std::cin >> num;
numbers.push_back(num);
}
// Bubble Sorting
for (int i = 0; (i < n) && (swap_check); i++) {
for (int i = 0; (i < n) && (swap_check); i++)
{
swap_check = false;
for (int j = 0; j < n - 1 - i; j++) {
if (numbers[j] > numbers[j + 1]) {
for (int j = 0; j < n - 1 - i; j++)
{
if (numbers[j] > numbers[j + 1])
{
swap_check = true;
std::swap(numbers[j],
numbers[j + 1]); // by changing swap location.
@@ -72,10 +77,14 @@ int main() {
// Output
std::cout << "\nSorted Array : ";
for (int i = 0; i < numbers.size(); i++) {
if (i != numbers.size() - 1) {
for (int i = 0; i < numbers.size(); i++)
{
if (i != numbers.size() - 1)
{
std::cout << numbers[i] << ", ";
} else {
}
else
{
std::cout << numbers[i] << std::endl;
}
}