====== 2012 ======
Az iskola.be állomány tartalma:
3 4 1
1 1 1 6
1 1 2 2
1 2 1 3
2 1 2 2
2 2 3 1
3 4 1 2
3 2 1 4
3 3 2 1
A program kód...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace iskola
{
class Program
{
static void Main(string[] args)
{
StreamReader be = new StreamReader("iskola.be");
string line;
line = be.ReadLine();
int tanarDb = Convert.ToInt32(line.Split(' ')[0]);
int targyDb = Convert.ToInt32(line.Split(' ')[1]);
int tanarIndex = Convert.ToInt32(line.Split(' ')[2])-1;
int[, ,] orak = new int[tanarDb, 5, 9];
while ((line = be.ReadLine()) != null)
{
int tanIndex = Convert.ToInt32(line.Split(' ')[0])-1;
int tarIndex = Convert.ToInt32(line.Split(' ')[1]);
int nap = Convert.ToInt32(line.Split(' ')[2])-1;
int ora = Convert.ToInt32(line.Split(' ')[3]);
orak[tanIndex, nap, ora] = tarIndex;
}
be.Close();
Console.WriteLine("Tanárok száma: {0}\nTárgyak száma: {1}\nVálasztott tanár: {2}", tanarDb, targyDb, tanarIndex);
for (int tan = 0; tan < tanarDb; tan++)
{
for (int nap = 0; nap < 5; nap++)
{
for (int ora=0; ora < 9; ora++)
{
if (orak[tan, nap, ora] != 0)
{
Console.WriteLine("tanár: {0}, nap: {1}, ora: {2}, tárgy: {3}", tan+1, nap+1, ora, orak[tan, nap, ora]);
}
}
}
}
// A) melyik nap hány tanár tanított
for (int nap = 0; nap < 5; nap++)
{
int db = 0; // Az adott napon tanító tanárok száma
for (int tan = 0; tan < tanarDb; tan++)
{
int ora = 0;
while (ora < 9 && orak[tan, nap, ora] == 0)
{
ora++;
}
if (ora < 9) db++;
}
Console.Write(db);
if (nap < 4) Console.Write(" ");
}
Console.ReadKey();
}
}
}