Загрузка данных


using System;
using System.Collections.Generic;

class Program
{
    static int w = 8, h = 8;
    static bool[,] used = new bool[8, 8];
    static Random r = new Random();

    static void Main()
    {
        Lab(0, 0);
        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
                Console.Write(used[x, y] ? ". " : "# ");
            Console.WriteLine();
        }
        Console.ReadKey();
    }

    static void Lab(int x, int y)
    {
        used[x, y] = true;

        List<int> d = new List<int> { 0, 1, 2, 3 };
        for (int i = 0; i < d.Count; i++)
        {
            int j = r.Next(d.Count);
            int t = d[i];
            d[i] = d[j];
            d[j] = t;
        }

        foreach (int k in d)
        {
            int nx = x, ny = y;

            if (k == 0) ny--;
            if (k == 1) ny++;
            if (k == 2) nx--;
            if (k == 3) nx++;

            if (nx >= 0 && ny >= 0 && nx < w && ny < h && !used[nx, ny])
                Lab(nx, ny);
        }
    }
}