예제 #1
0
파일: Program.cs 프로젝트: 0x0all/MyProgram
        static void Main(string[] args)
        {
            Stack stack = new Stack();
           	int whatDo = -1;
	        while (whatDo != 0)
	        {
		        Console.WriteLine("0 - exit"); 
			    Console.WriteLine("1 - push"); 
			    Console.WriteLine("2 - pop"); 
			    whatDo = Convert.ToInt32(Console.ReadLine());
		        if (whatDo == 1)
		        {
			        int newNum = 0;
			        Console.WriteLine("Enter number for add - ");
			        newNum = Convert.ToInt32(Console.ReadLine());
			        stack.Push(newNum);
		        }
		        if (whatDo == 2)
		        {
                    int value = stack.Pop();
                    if (value == -1)
                        Console.WriteLine("Stack is empty");
                    else
                        Console.WriteLine("delete element - {0}", value);
			    }
		        stack.Print();
		    }
        }
예제 #2
0
 public void Initialize()
 {
     stack = new Stack<int>();
 }
예제 #3
0
 public Calculator(Stack newStack)
 {
     stack = newStack;
 }