Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _4._7
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] integers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- writeArray(integers);
- Console.WriteLine();
- shuffle(ref integers);
- writeArray(integers);
- }
- static void shuffle(ref int[] array)
- {
- Random random = new Random();
- for (int i = array.Length - 1; i > 0; i--)
- {
- int randomValue = random.Next(i);
- int value = array[i];
- array[i] = array[randomValue];
- array[randomValue] = value;
- }
- }
- static void writeArray(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement