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 _4_6
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random r = new Random();
- //int[] array = new int[30];
- int[] array = {2,4,6,2,5,45,3 };
- /*for (int i = 0; i < array.Length; i++)
- {
- array[i] = r.Next(0, 78);
- Console.Write(array[i] + " ");
- }*/
- for (int i = 0; i < array.Length; i++)
- Console.Write(array[i] + " ");
- Console.WriteLine();
- Shuffle(array);
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- }
- static void Shuffle(int[] array)
- {
- Random r = new Random();
- for (int i = array.Length - 1; i >= 1 ; i--)
- {
- int random = r.Next(i + 1);
- int t = array[random];
- array[random] = array[i];
- array[i] = t;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement