Example #1
0
 public void push(nod value)
 {
     n++;
     nod[] t = new nod[n];
     for (int i = 0; i < n - 1; i++)
     {
         t[i + 1] = v[i];
     }
     t[0] = value;
     v    = t;
 }
Example #2
0
        public nod pop()
        {
            nod tor = v[n - 1];

            n--;
            nod[] t = new nod[n];
            for (int i = 0; i < n; i++)
            {
                t[i] = v[i];
            }
            v = t;
            return(tor);
        }
Example #3
0
        static void Lee()
        {
            Queue D = new Queue();

            a[0, 0] = 1;
            D.push(new nod(0, 0, 1));

            while (D.n != 0)
            {
                nod t = D.pop();
                if (t.l - 1 >= 0)
                {
                    if (a[t.l - 1, t.c] == 0)
                    {
                        a[t.l - 1, t.c] = t.v + 1;
                        D.push(new nod(t.l - 1, t.c, t.v + 1));
                    }
                }
                if (t.c + 1 < m)
                {
                    if (a[t.l, t.c + 1] == 0)
                    {
                        a[t.l, t.c + 1] = t.v + 1;
                        D.push(new nod(t.l, t.c + 1, t.v + 1));
                    }
                }
                if (t.l + 1 < n)
                {
                    if (a[t.l + 1, t.c] == 0)
                    {
                        a[t.l + 1, t.c] = t.v + 1;
                        D.push(new nod(t.l + 1, t.c, t.v + 1));
                    }
                }
                if (t.c - 1 >= 0)
                {
                    if (a[t.l, t.c - 1] == 0)
                    {
                        a[t.l, t.c - 1] = t.v + 1;
                        D.push(new nod(t.l, t.c - 1, t.v + 1));
                    }
                }
            }
        }