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 ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] massiv = new int[5] { 1, 2, 3, 4, 5 };
- Console.WriteLine("Исходный массив");
- PrintArray(massiv);
- Console.WriteLine("\nПеремешанный массив");
- PrintArray(Shuffle(massiv));
- Console.WriteLine();
- }
- static int[] Shuffle(int[] arr)
- {
- Random rand = new Random();
- for (int i = 0; i < arr.Length; i++)
- {
- int n = rand.Next(arr.Length);
- int m = arr[i];
- arr[i] = arr[n];
- arr[n] = m;
- }
- return arr;
- }
- static void PrintArray(int[] printArr)
- {
- for (int i = 0; i < printArr.Length; i++)
- {
- Console.Write(printArr[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement