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 Tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- Shuffle(array1);
- Console.WriteLine(" ");
- Console.WriteLine("Матрица после перетасовки.");
- for (int i = 0; i < array1.Length; i++)
- {
- Console.Write(array1[i] + " ");
- }
- }
- static void Shuffle(int[] array)
- {
- Random rand = new Random();
- for (int i = array.Length - 1; i >= 0; i--)
- {
- int elementIndexForChange = rand.Next(0, i + 1);
- int temporaryPlace = array[elementIndexForChange];
- array[elementIndexForChange] = array[i];
- array[i] = temporaryPlace;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement