//¹®Á¦ 3. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ¾²½Ã¿À. using System; namespace Test3 { class Stack { static int[] s; static int top; public Stack() { s = new int[2]; top = -1; } public void push(int x) { if (top >= s.Length-1) { s = new int[s.Length * 2]; } top++; s[top] = x; } public int pop() { top--; return s[top]; } public void print() { for (int i = 0; i < s.Length; i++) { if (s[i] != 0) Console.Write(s[i]); } Console.WriteLine(); } } class Program { static void Main(string[] args) { int[] data = { 1, 2, 3, 4, 5 }; Stack s1 = new Stack(); Stack s2 = new Stack(); for (int i = 0; i < data.Length; i++) { s1.push(data[i]); s2.push(data[i]); } s1.pop(); s1.pop(); s1.pop(); s2.pop(); s1.print(); s2.print(); } } }