Ejemplo n.º 1
0
        public void test_Stack()
        {
            Stack s = new Stack();

            s.push(99);
            s.push(45);
            s.push(7);
            s.displayStack();

            Console.WriteLine("peek: " + s.peek());

            Console.WriteLine("pop: ");
            s.pop();

            Console.WriteLine("peek: " + s.peek());
        }
Ejemplo n.º 2
0
        static void Main()
        {
            int n;

            Console.Write("Nhap so can doi:");
            n = int.Parse(Console.ReadLine());
            Stack  T  = new Stack();
            string st = "0123456789ABCDEF";

            while (n != 0)
            {
                T.push((int)st[n % 16]);
                n = n / 16;
            }
            Console.Write("Ket qua doi sang hexa :");
            while (!T.empty())
            {
                Console.Write("{0}", (char)T.pop());
            }
            Console.ReadLine();
        }