コード例 #1
0
 internal void pop()
 {
     Console.WriteLine($"{array[top - 1]}出栈");
     array[top - 1] = 0;
     top--;
     ArrayShow.Inline(array);
     Console.WriteLine();
     Console.WriteLine("--------------------");
     if (top == array.Length)
     {
         Console.WriteLine("栈溢出");
     }
     else if (top == 0)
     {
         Console.WriteLine("栈已空");
     }
 }
コード例 #2
0
        internal void Push(params object[] value)
        {
            if (top == array.Length)
            {
                Console.WriteLine("栈溢出");
            }
            else
            {
                for (int i = 0; i < value.Length; i++)
                {
                    array[top] = value[i];
                    top++;
                    Console.Write($"{value[i]},");
                }

                Console.WriteLine("入栈");

                ArrayShow.Inline(array);
                Console.WriteLine();
                Console.WriteLine("--------------------");
            }
        }