Created
April 22, 2025 10:32
-
-
Save IvanVologda/3d34a39acc63cb79b1e5c62461494a6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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