Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework33
- {
- class Program
- {
- static void Main()
- {
- int[] array = { 2, 5, 7, 9, 10, 13, 14 };
- Console.WriteLine("Исходный массив: ");
- OutputElementsOfArray(array);
- array = Shuffle(array);
- Console.WriteLine("\nМассив с перемешанными значениями: ");
- OutputElementsOfArray(array);
- }
- static int[] Shuffle(int[] originalArray)
- {
- Random random = new Random();
- for (int i = 0; i < originalArray.Length; i++)
- {
- int randomElement = random.Next(0, originalArray.Length);
- int temp = originalArray[randomElement];
- originalArray[randomElement] = originalArray[i];
- originalArray[i] = temp;
- }
- return originalArray;
- }
- static void OutputElementsOfArray(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement