mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-05 14:45:55 +08:00
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>
This commit is contained in:
committed by
GitHub
parent
2487a27036
commit
954c45864b
36
ja/codes/python/chapter_stack_and_queue/stack.py
Normal file
36
ja/codes/python/chapter_stack_and_queue/stack.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""
|
||||
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)
|
||||
Reference in New Issue
Block a user