Informatika gyűjtemény

Egy szinttel feljebb dm_lab.cs

2004050607080910

NézetNyomtat

dm_lab.cs (Vissza)
Az alábbi letöltési lehetőségek közül választhatsz: (segítség)
Karakterkódolás:
Sortörés:
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 2 KB
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace labirintus {

class vect2d {
    public int x;
    public int y;
}

class Program {

public static bool[,] data;
public static bool[,] data2;
public static int n;

static void Main(string[] args)

{

StreamReader sr = new StreamReader("lab15.txt");

= Int32.Parse(sr.ReadLine())+2;
data = new bool[n, n];
data2 = new bool[n, n];

for (int i = 0; i < n; i++)

{

string s = sr.ReadLine();

for (int k = 0; k < n; k++)

{

if (s[k] != ' ') {

data[i, k] =
true;

data2[i, k] =
true;

}

}

}

sr.Close();

////kitlts

for (; ; )

{

bool volt = false;

for (int i = 1; i < n - 1; i++)

{

for (int k = 1; k < n - 1; k++)

{

if (data[i, k]) continue;

int counter = 0;

if (data[- 1, k]) counter++;

if (data[+ 1, k]) counter++;

if (data[i, k - 1]) counter++;

if (data[i, k + 1]) counter++;

if (counter > 2)

{

data[i, k] =
true;

volt =
true;

/*dump();

Console.Write("\n");

Console.ReadKey(true);*/

}

}

}

if (!volt) break;

}

output();

Console.ReadKey(true);

vect2d now = new vect2d();

now.= 0;

now.= 1;

vect2d last = new vect2d();

last.= now.x;

last.= now.y;

data[1, 0] =
true;

for (; ; )

{

bool volt = false;

for (int i = 1; i < n - 1; i++)

{

for (int k = 1; k < n - 1; k++)

{

if (data[i, k]) continue;

int counter = 0;

if (data[- 1, k]) counter++;

if (data[+ 1, k]) counter++;

if (data[i, k - 1]) counter++;

if (data[i, k + 1]) counter++;

if (counter > 2)

{

data[i, k] =
true;

volt =
true;

now.= k;

now.= i;

if(now.== last.x){

if(now.> last.y){

Console.WriteLine("LE");

}

else {

Console.WriteLine("FEL");

}

}

if(now.== last.y){

if(now.> last.x){

Console.WriteLine("JOBBRA");

}

else {

Console.WriteLine("BALRA");

}

}

last.= now.x;

last.= now.y;

/*dump();

Console.Write("\n");

Console.ReadKey(true);*/

}

}

}

if (!volt) break;

}

Console.WriteLine("JOBBRA");

Console.ReadKey(true);

}

static void output()

{

for (int i = 0; i < n; i++)

{

for (int k = 0; k < n; k++)

{

if (!data[i, k]) Console.Write("*");

else if (data2[i, k]) Console.Write("#");

else Console.Write(" ");

}

Console.WriteLine();

}

}

static void dump() {

for (int i = 0; i < n; i++)

{

for (int k = 0; k < n; k++)

{

if (data[i, k]) Console.Write("#");

else Console.Write(" ");

}

Console.WriteLine();

}

}

}

}
(Vissza)