Skip to content

Instantly share code, notes, and snippets.

@MagSosiq
Created June 29, 2024 18:43
Show Gist options
  • Save MagSosiq/e79ed8b0cdca37ee7e164f9f77d642f2 to your computer and use it in GitHub Desktop.
Save MagSosiq/e79ed8b0cdca37ee7e164f9f77d642f2 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace HW1
{
internal class Program
{
static void Main(string[] args)
{
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
Random random = new Random();
int[] numbers = new int[10];
int temporary;
Console.Write("Наш изначальный массив: ");
for (int i = 0; i < numbers.Length; i++)
{
numbers[i] = random.Next(-10, 11);
Console.Write(numbers[i] + " ");
}
Console.WriteLine();
for (int i = 0; i < numbers.Length; i++)
{
for (int j = 0; j < numbers.Length - 1 - i; j++)
{
if (numbers[j] > numbers[j + 1])
{
temporary = numbers[j];
numbers[j] = numbers[j + 1];
numbers[j + 1] = temporary;
}
}
}
Console.WriteLine("Наш отсортированный массив: ");
for (int i = 0; i < numbers.Length; i++)
{
Console.Write(numbers[i] + " ");
}
Console.WriteLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment