Maha

Maha

  • NA
  • 0
  • 323.9k

Audience and Seat#

Oct 10 2013 2:53 PM
Only one seat should be allocated to one audience randomly. More than one audience can't have same seat or vice versa. How can this program be completed with these conditions?

using System;

class Program
{
public static void Main()
{
int seats = 10;
int audience = 10;

int[] audArray = new int[audience];

Random r = new Random();

Console.WriteLine("{0 ,4} {1, 5}", "Audience", "Seat#");

for (int i = 1; i < audience; i++)
{
int x = r.Next(1, seats);

audArray[i] = i;

Console.WriteLine("{0, 3} {1, 6}", audArray[i], x);

}
Console.Read();
}
}


Answers (7)