Advertisement
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 ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- bool isOpen = true;
- int[] array = new int[10];
- Console.WriteLine("Чтобы перемешать массив нажмите 5");
- Console.WriteLine("Чтобы выйти нажмите любую другую кнопку");
- CompletionArray(array);
- while (isOpen)
- {
- if (Console.ReadLine() == "5")
- {
- array = Shuffle(array);
- }
- else
- {
- isOpen = false;
- }
- Console.WriteLine();
- }
- }
- static void CompletionArray (int[] array)
- {
- Random rand = new Random();
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = rand.Next(10, 99);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- }
- static int[] Shuffle (int [] array)
- {
- Random rand = new Random();
- for (int i = array.Length - 1; i >= 0; i--)
- {
- int j = rand.Next(i + 1);
- int n = array[j];
- array[j] = array[i];
- array[i] = n;
- Console.Write(array[i] + " ");
- }
- return array;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement