Example #1
0
        static void Main(string[] args)
        {
            Stack1 objstack1 = new Stack1();
            Stack2 objstack2 = new Stack2();
            int    input     = int.Parse(Console.ReadLine());

            for (int i = 0; i < input; i++)
            {
                string   val    = Console.ReadLine();
                string[] values = val.Split(' ');
                if (values[0] == "1")
                {
                    objstack1.push(int.Parse(values[1]));
                }
                else if (values[0] == "2")
                {
                    int chk;
                    if (objstack2.empty())
                    {
                        while ((chk = objstack1.pop()) != 0)
                        {
                            objstack2.push(chk);
                        }
                    }
                    objstack2.pop();
                    //int chk2;
                    //while ((chk2= objstack2.pop()) != 0)
                    //{

                    //    objstack1.push(chk2);
                    //}
                }
                else
                {
                    int chk3;
                    if (objstack2.empty())
                    {
                        while ((chk3 = objstack1.pop()) != 0)
                        {
                            objstack2.push(chk3);
                        }
                    }
                    Console.WriteLine(objstack2.print());
                    //int chk4;
                    //while ((chk4=objstack2.pop() )!= 0)
                    //{

                    //    objstack1.push(chk4);
                    //}
                }
            }
            Console.ReadKey();
        }
Example #2
0
    public static void Main(string[] args)
    {
        Stack2 s = new Stack2(10);

        for (int i = 1; i <= 100; i++)
        {
            s.Push(i);
        }
        for (int i = 1; i <= 100; i++)
        {
            s.Pop();
        }
        s.print();
    }