mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-23 20:22:56 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -8,7 +8,7 @@ Author: krahets (krahets@163.com)
|
||||
def for_loop(n: int) -> int:
|
||||
"""for ループ"""
|
||||
res = 0
|
||||
# 1, 2, ..., n-1, n を順に加算する
|
||||
# ループで 1, 2, ..., n-1, n の和を求める
|
||||
for i in range(1, n + 1):
|
||||
res += i
|
||||
return res
|
||||
@@ -18,7 +18,7 @@ def while_loop(n: int) -> int:
|
||||
"""while ループ"""
|
||||
res = 0
|
||||
i = 1 # 条件変数を初期化する
|
||||
# 1, 2, ..., n-1, n を順に加算する
|
||||
# ループで 1, 2, ..., n-1, n の和を求める
|
||||
while i <= n:
|
||||
res += i
|
||||
i += 1 # 条件変数を更新する
|
||||
@@ -26,10 +26,10 @@ def while_loop(n: int) -> int:
|
||||
|
||||
|
||||
def while_loop_ii(n: int) -> int:
|
||||
"""while ループ(2回更新)"""
|
||||
"""while ループ(2 回の更新)"""
|
||||
res = 0
|
||||
i = 1 # 条件変数を初期化する
|
||||
# 1, 4, 10, ... を順に加算する
|
||||
# ループで 1, 4, 10, ... の和を求める
|
||||
while i <= n:
|
||||
res += i
|
||||
# 条件変数を更新する
|
||||
@@ -41,25 +41,25 @@ def while_loop_ii(n: int) -> int:
|
||||
def nested_for_loop(n: int) -> str:
|
||||
"""二重 for ループ"""
|
||||
res = ""
|
||||
# i = 1, 2, ..., n-1, n とループする
|
||||
# i = 1, 2, ..., n-1, n のループ
|
||||
for i in range(1, n + 1):
|
||||
# j = 1, 2, ..., n-1, n とループする
|
||||
# j = 1, 2, ..., n-1, n のループ
|
||||
for j in range(1, n + 1):
|
||||
res += f"({i}, {j}), "
|
||||
return res
|
||||
|
||||
|
||||
"""Driver Code"""
|
||||
"""実行用コード"""
|
||||
if __name__ == "__main__":
|
||||
n = 5
|
||||
res = for_loop(n)
|
||||
print(f"\nfor ループの合計結果 res = {res}")
|
||||
print(f"\nfor ループで求めた和 res = {res}")
|
||||
|
||||
res = while_loop(n)
|
||||
print(f"\nwhile ループの合計結果 res = {res}")
|
||||
print(f"\nwhile ループで求めた和 res = {res}")
|
||||
|
||||
res = while_loop_ii(n)
|
||||
print(f"\nwhile ループ(2 回更新)の合計結果 res = {res}")
|
||||
print(f"\nwhile ループ(2 回の更新)で求めた和 res = {res}")
|
||||
|
||||
res = nested_for_loop(n)
|
||||
print(f"\n二重 for ループの走査結果 {res}")
|
||||
|
||||
Reference in New Issue
Block a user