Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ポップアウトされたデータをスタックの一番上から永久に削除したい
return Stack[top--]!
しかし、再びポップアウトを呼び出すと、最後にポップされた値と同じになります!! ヒントが表示されたら、データを削除する方法を教えてください。
よろしくお願いします(Javaコードを使用したヒントが必要です)
public static void main(String args[]) { Stack stack = new Stack(); for (int i = 1; i <= 10; i++) stack.push(new Integer(i)); while (!stack.empty()) System.out.print(stack.pop() + " "); System.out.println(" No element in stack"); }
これは私にとってはうまくいきます。