Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C# Sharp Online

using System;
namespace Rextester
{
class Test
{
     public  void LevelLoad(int[] ar)
    {
      int n=ar.Length;
      Random rand= new Random();
      for(int i=0;i<n;i++)
      {
          Swap(ar,i,i+rand.Next(n-i));
      }
    }
 public void Swap(int[] ar,int a,int b)
    {
     int temp=ar[a];
     ar[a]=ar[b];
     ar[b]=temp;
    } 
}
class Program
{
static void Main(string[] args)
{
     
   int[] arr= new int[] { 1, 2, 3 ,4,5,6,7,8};
    Test t=new Test();
    t.LevelLoad(arr);
    Console.WriteLine("..................................");
    for(int j=0;j<arr.Length;j++)
      {
          Console.WriteLine(arr[j]);
      }

    //...............................
   
}
}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.