Files
Ikko Eltociear Ashimine 954c45864b docs: add Japanese translate documents (#1812)
* docs: add Japanese documents (`ja/docs`)

* docs: add Japanese documents (`ja/codes`)

* docs: add Japanese documents

* Remove pythontutor blocks in ja/

* Add an empty at the end of each markdown file.

* Add the missing figures (use the English version temporarily).

* Add index.md for Japanese version.

* Add index.html for Japanese version.

* Add missing index.assets

* Fix backtracking_algorithm.md for Japanese version.

* Add avatar_eltociear.jpg. Fix image links on the Japanese landing page.

* Add the Japanese banner.

---------

Co-authored-by: krahets <krahets@163.com>
2025-10-17 05:04:43 +08:00

36 lines
1009 B
Python

"""
File: stack.py
Created Time: 2022-11-29
Author: Peng Chen (pengchzn@gmail.com)
"""
"""Driver Code"""
if __name__ == "__main__":
# スタックを初期化
# Pythonには組み込みのスタッククラスはありませんが、リストをスタックとして使用できます
stack: list[int] = []
# 要素をプッシュ
stack.append(1)
stack.append(3)
stack.append(2)
stack.append(5)
stack.append(4)
print("スタック stack =", stack)
# スタックトップ要素にアクセス
peek: int = stack[-1]
print("スタックトップ要素 peek =", peek)
# 要素をポップ
pop: int = stack.pop()
print("ポップされた要素 pop =", pop)
print("ポップ後のスタック =", stack)
# スタックの長さを取得
size: int = len(stack)
print("スタックの長さ size =", size)
# 空かどうかを判定
is_empty: bool = len(stack) == 0
print("スタックが空かどうか =", is_empty)