Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HomeWork
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- Random random = new Random();
- int[] numbers = new int[10];
- int maxRandomNumber = 10;
- Console.WriteLine("Исходный массив:");
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(maxRandomNumber);
- Console.Write(numbers[i] + " ");
- }
- Console.WriteLine();
- for (int i = 0; i < numbers.Length - 1; i++)
- {
- for (int j = 0; j < numbers.Length - i - 1; j++)
- {
- if (numbers[j] > numbers[j + 1])
- {
- int temp = numbers[j];
- numbers[j] = numbers[j + 1];
- numbers[j + 1] = temp;
- }
- }
- }
- Console.WriteLine("\nОтсортированный массив:");
- for (int i = 0; i < numbers.Length; i++)
- Console.Write(numbers[i] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement