Skip to content

Instantly share code, notes, and snippets.

@FleamRus
Created May 6, 2024 01:34
Show Gist options
  • Save FleamRus/a2ea948f43ce07cbd707b000f1fe1e90 to your computer and use it in GitHub Desktop.
Save FleamRus/a2ea948f43ce07cbd707b000f1fe1e90 to your computer and use it in GitHub Desktop.
Сортировка чисел
using System;
namespace Сортировка_чисел
{
internal class Program
{
static void Main(string[] args)
{
Random random = new Random();
int minRandom = 1;
int maxRandom = 10;
int[] numbers = new int[10];
Console.WriteLine("Массив: \n");
for (int i = 0; i < numbers.Length; i++)
{
numbers[i] = random.Next(minRandom, maxRandom);
Console.Write(numbers[i] + " ");
}
Console.WriteLine("\nСортированные числа: ");
for (int i = 0; i < numbers.Length; i++)
for (int j = 0; j < numbers.Length - 1; j++)
if (numbers[j] > numbers[j + 1])
{
int t = numbers[j + 1];
numbers[j + 1] = numbers[j];
numbers[j] = t;
}
foreach (int number in numbers)
Console.WriteLine(number);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment