//문제 3. 다음 프로그램의 출력을 쓰시오. using System; namespace Test3 { class Stack { int[] s; public Stack() { s = new int[2]; } public void push(int x) { int[] ss = new int[s.Length + 2]; for (int i = 0; i < s.Length; i++) { ss[2 + i] = s[i]; } ss[0] = x; ss[1] = x; s = ss; } public void pop() { s[0] = 0; } public void print() { for (int i = 0; i < s.Length; i++) { Console.Write(s[i]); } Console.WriteLine(); } } class Program { static void Main(string[] args) { int[] data = { 1, 2, 3, 4, 5 }; Stack stack = new Stack(); for (int i = 0; i < data.Length; i++) { stack.push(data[i]); stack.pop(); } stack.print(); } } }