Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HW
- {
- class Program
- {
- static void Main(string[] args)
- {
- int arrayLength = 10;
- int arrayValues = 25;
- int temporaryValue;
- int[] array = new int[arrayLength];
- Random random = new Random();
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(arrayValues);
- Console.Write(array[i] + " ");
- }
- for (int j = 0; j < array.Length; j++)
- {
- for (int i = 0; i < array.Length - 1; i++)
- {
- int index = i;
- if (array[index] > array[++index])
- {
- temporaryValue = array[index];
- array[index] = array[--index];
- array[index] = temporaryValue;
- }
- }
- }
- Console.WriteLine();
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment