Advertisement
Guest User

Untitled

a guest
May 26th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp3
  8. {
  9.     class MainClass
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             int[] massive = new int[10];
  14.  
  15.             drawMassive(massive);
  16.             Shuffle(massive);
  17.             Console.ReadKey();
  18.         }
  19.         public static void drawMassive(int[] massive)
  20.         {
  21.             Random rand = new Random();
  22.             for (int i = 0; i < massive.Length; i++)
  23.             {
  24.                 massive[i] = rand.Next(10, 100);
  25.                 Console.Write(massive[i] + " ");
  26.             }
  27.             Console.WriteLine();
  28.         }
  29.         public static void Shuffle(int[] massive)
  30.         {
  31.             Random rand = new Random();
  32.             for (int i = massive.Length - 1; i >= 0; i--)
  33.             {
  34.                 int j = rand.Next(i + 1);
  35.                 int tmp = massive[j];
  36.                 massive[j] = massive[i];
  37.                 massive[i] = tmp;
  38.                 Console.Write(massive[i] + " ");
  39.             }
  40.             Console.WriteLine();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement