Skip to content

Instantly share code, notes, and snippets.

@IvanVologda
Created April 22, 2025 10:32
Show Gist options
  • Save IvanVologda/3d34a39acc63cb79b1e5c62461494a6d to your computer and use it in GitHub Desktop.
Save IvanVologda/3d34a39acc63cb79b1e5c62461494a6d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ДомашняяРабота23
{
internal class Program
{
static void Main(string[] args)
{
int[] bubleSorting = new int[10];
Random random = new Random();
int lowerLimit = 0;
int upperLimit = 10;
int largerNumber;
bool isSorting = true;
for (int i = 0; i < bubleSorting.Length; i++)
{
bubleSorting[i] = random.Next(lowerLimit, upperLimit);
}
while (isSorting)
{
isSorting = false;
for (int i = 1; i < bubleSorting.Length; i++)
{
if (bubleSorting[i] < bubleSorting[i - 1])
{
largerNumber = bubleSorting[i];
bubleSorting[i] = bubleSorting[i - 1];
bubleSorting[i - 1] = largerNumber;
isSorting = true;
}
}
}
for (int i = 0; i < bubleSorting.Length; i++)
{
Console.Write(bubleSorting[i] + " ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment