Algorithm Implementation Source Code:: Program
Algorithm Implementation Source Code:: Program
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static string[, ,] Seat = new string[100, 100, 100];
static string[, ,] initialSeat = new string[100,100,100];
static string[, ,] initialsub = new string[100,100,100];
static string[] subjectcode = { "11cs101", "11ee203", "11ec309" };
static string[,] rollnosub ={
{"12bcs059","12bcs060","12bcs061","12bcs062","12bcs063","12bcs064","12bcs065","12bcs066",
"12bcs067","12bcs068"},
{"12bee059","12bee060","12bee061","12bee062","12bee063","12bee064","12bee065","12bee066",
"12bee067","12bee068"},
{"12bec059","12bec060","12bec061","12bec062","12bec063","12bec064","12bec065","12bec066",
"12bec067","12bec068"},
};
static string[] hallname = { "a201", "a202", "a203" };
static int[] Row = { 5, 5, 5 };
static int[] Column = { 2, 2, 2 };
static int grouplimit = 3, cgrouplimit = 3, limit, noofgroups = 3;
return false;
}
}
else
{
}
}
}
return true;
}
static void graphcolor()
{
cgrouplimit = grouplimit;
for (limit = 0; limit < grouplimit; limit++)
{
groups[limit] = limit;
}
for (limit = 0; limit < noofgroups; limit++)
{
rolllimit[limit] = 0;
}
limit = 0;
for (int hall = 0; hall < hallname.Length; hall++)
{
for (int row = 0; row < Row[hall]; row++)
{
for (int col = 0; col < Column[hall]; )
{
if (row == 0)
{
Seat[hall, row, col] = rollnosub[groups[limit],
rolllimit[groups[limit]]];
initialsub[hall, row, col] = subjectcode[groups[limit]];
}
else
{
if (subjectcode[groups[limit]] == initialsub[hall, row -
1, col])
{
limit++;
if (limit == grouplimit)
{
limit = 0;
}
Seat[hall, row, col] = rollnosub[groups[limit],
rolllimit[groups[limit]]];
initialsub[hall, row, col] =
subjectcode[groups[limit]];
}
else
{
Seat[hall, row, col] = rollnosub[groups[limit],
rolllimit[groups[limit]]];
initialsub[hall, row, col] =
subjectcode[groups[limit]];
}
}
++col;
if (++(rolllimit[groups[limit]]) != 10)
{
limit++;
}
else
{
groups[limit] = cgrouplimit++;
limit++;
}
if (limit == grouplimit)
{
limit = 0;
}
}
}
Console.ReadLine();
}
static void Main(string[] args)
{
try
{
initializeseats();
for (int hall = 0; hall < hallname.Length; hall++)
{
if (isgraphcoloring(hall))
{
for (int row = 0; row < Row[hall]; row++)
{
for (int col = 0; col < Column[hall]; col++)
{
Seat[hall, row, col] = initialSeat[hall, row, col];
}
}
}
else
{
graphcolor();
}
}
Console.WriteLine("**************SEATING ARRANGEMENTS**************");
for (int hall = 0; hall < hallname.Length; hall++)
{
Console.WriteLine("HALL NUMBER = "+hallname[hall]);
int seatno = 1;
for (int row = 0; row < Row[hall]; row++)
{
for (int seatnum = 0; seatnum < Column[hall]; seatnum++)
{
Console.Write("\t "+seatno++ +" ");
}
Console.WriteLine();
for (int col = 0; col < Column[hall]; col++)
{
Console.Write("\t"+Seat[hall, row, col] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
Console.Read();
}
catch(Exception e)
{
}
}
}
}