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