static void Main(string[] args)
        {
            stack s = new stack(5);

            s.push(10);
            s.pop(); s.print();
            s.push(1);
            s.push(2);
        }
示例#2
0
        public static stack operator +(stack s, stack s2)
        {
            stack temp = new stack();

            temp.size = s.size + s2.size;
            temp.tos  = s.tos + s2.tos;

            return(temp);
        }
示例#3
0
 public stack(stack s)
 {
     this.size = s.size;
     this.tos  = s.tos;
     this.arr  = new int[s.arr.Length];
     for (int i = 0; i < s.tos; i++)
     {
         this.arr[i] = s.arr[i];
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            stack One = new stack(3);

            One.push(1);
            One.push(2);
            One.push(3);
            One.push(4);
            One.print();
            One.pop();
            One.pop();
            One.pop();
            One.pop();
            One.print();
        }
示例#5
0
        static void Main(string[] args)
        {
            stack s = new stack(5);

            s.push(4);
            s.push(3);

            stack s2 = new stack(4);

            s2.push(7);
            s2.push(9);

            stack s3 = s2 + s;


            Console.WriteLine(s3.ToString());


            //s.push("5");
            //s.push("6");
            //s.push("7");
            //Console.WriteLine(s.ToString());

            //s.pop();


            //Console.WriteLine(s.ToString());



            //stack s = new stack(5);
            //s.push(2);
            //s.push(4);
            //s.push(5);

            //stack s2 = new stack(s);


            //s2.push(7);
            // Console.WriteLine(s.pop());
            //  Console.WriteLine(s.ToString());
            // Console.WriteLine(s2.ToString());
        }
示例#6
0
        static void Main(string[] args)
        {
            stack test = new stack(10);

            test.push(5);
            test.push(6);
            test.pop();
            test.peek();
            stack other = new Stack.stack(5);

            other.push(1);
            other.push(2);
            other.push(500);
            Console.WriteLine(other.pop() + " has been popped");
            other.push(3);
            other.push(4);
            other.push(5);
            other.push(6);
            other.peek();
            Console.ReadLine();
        }