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