Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp11
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Введите объём массива - ");
- int volume = Convert.ToInt32(Console.ReadLine());
- int[] array = new int[volume];
- Console.WriteLine("Заполните массив:");
- FillingArray(array);
- Shuffle(array);
- Console.WriteLine("Ваш массив перемешан:");
- DrawArray(array);
- }
- static void Shuffle(int[] array)
- {
- Random rnd = new Random();
- for (int j = 0; j < rnd.Next(); j++)
- for (int i = 0; i < array.Length - 1; i++)
- {
- int number = array[i];
- array[i] = array[i + 1];
- array[i + 1] = number;
- }
- }
- static void FillingArray(int [] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write($"{i + 1} - ");
- array[i] = Convert.ToInt32(Console.ReadLine());
- }
- Console.Clear();
- }
- static void DrawArray(int [] array)
- {
- for (int i = 0; i < array.Length; i++)
- Console.Write(array[i] + " ");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement