public static void Main()
Console.WriteLine("Please Enter Number Of Teams");
int numberOfTeams = Convert.ToInt32(Console.ReadLine());
Program p = new Program();
int[,] result = p.GenerateRoundRobin(numberOfTeams);
for (int k = 0; k < result.GetLength(1); k++)
Console.WriteLine("Round {0}", k + 1);
for (int i = 0; i < result.GetLength(0); i++)
for (int j = 0; j < result.GetLength(1); j++)
Console.WriteLine("Team {0} vs Team {1}", i + 1, result[i,j] + 1);
private const int BYE = -1;
private int [,] GenerateRoundRobinOdd(int num_teams)
int n2 = (int)((num_teams - 1) / 2);
int[,] results = new int[num_teams, num_teams];
int[] teams = new int[num_teams];
for (int i = 0; i < num_teams; i++) teams[i] = i;
for (int round = 0; round < num_teams; round++)
for (int i = 0; i < n2; i++)
int team1 = teams[n2 - i];
int team2 = teams[n2 + i + 1];
results[team1, round] = team2;
results[team2, round] = team1;
results[teams[0], round] = BYE;
private void RotateArray(int[] teams)
int tmp = teams[teams.Length - 1];
Array.Copy(teams, 0, teams, 1, teams.Length - 1);
private int[,] GenerateRoundRobinEven(int num_teams)
int[,] results = GenerateRoundRobinOdd(num_teams - 1);
int[,] results2 = new int[num_teams, num_teams - 1];
for (int team = 0; team < num_teams - 1; team++)
for (int round = 0; round < num_teams - 1; round++)
if (results[team, round] == BYE)
results2[team, round] = num_teams - 1;
results2[num_teams - 1, round] = team;
results2[team, round] = results[team, round];
private int[,] GenerateRoundRobin(int num_teams)
return GenerateRoundRobinEven(num_teams);
return GenerateRoundRobinOdd(num_teams);