private static void Solve1(string input, InOut.Ergebnis erg)
        {
            int            count = 0;
            LLStack <char> stack = new LLStack <char>();

            for (int i = 0; i < input.Length; i++)
            {
                count++;
                if (stack.Count == 0)
                {
                    stack.Push(input[i]);
                }
                else if (match.Keys.Contains <char>(input[i]))
                {
                    stack.Push(input[i]);
                }
                else if (match[stack.Peek()] == input[i])
                {
                    stack.Pop();
                }
                else
                {
                    break;
                }
            }
            erg.Setze(stack.Count == 0, count);
        }
예제 #2
0
    static void Main()
    {
        LLStack stack = new LLStack();

        double x1 = 2.56;
        string x2 = "String #2";
        char   x3 = 'r';
        Node   x4 = new Node("Node 4");
        int    x5 = 54664;

        stack.Push(x1);
        stack.Push(x2);
        stack.Push(x3);
        stack.Push(x4);
        stack.Push(x5);

        Console.WriteLine(stack.ToString());

        stack.Pop();
        stack.Pop();
        stack.Pop();
        stack.Pop();
        stack.Peek();
        stack.Pop();
        Console.WriteLine(stack.IsEmpty());
    }
예제 #3
0
 public int Peek() => stack.Peek();