mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-03 19:52:01 +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:
@@ -10,7 +10,7 @@ public class iteration {
|
||||
/* for ループ */
|
||||
static int forLoop(int n) {
|
||||
int res = 0;
|
||||
// 1, 2, ..., n-1, n を順に加算する
|
||||
// ループで 1, 2, ..., n-1, n の和を求める
|
||||
for (int i = 1; i <= n; i++) {
|
||||
res += i;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class iteration {
|
||||
static int whileLoop(int n) {
|
||||
int res = 0;
|
||||
int i = 1; // 条件変数を初期化する
|
||||
// 1, 2, ..., n-1, n を順に加算する
|
||||
// ループで 1, 2, ..., n-1, n の和を求める
|
||||
while (i <= n) {
|
||||
res += i;
|
||||
i++; // 条件変数を更新する
|
||||
@@ -29,11 +29,11 @@ public class iteration {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* while ループ(2回更新) */
|
||||
/* while ループ(2 回の更新) */
|
||||
static int whileLoopII(int n) {
|
||||
int res = 0;
|
||||
int i = 1; // 条件変数を初期化する
|
||||
// 1, 4, 10, ... を順に加算する
|
||||
// ループで 1, 4, 10, ... の和を求める
|
||||
while (i <= n) {
|
||||
res += i;
|
||||
// 条件変数を更新する
|
||||
@@ -46,9 +46,9 @@ public class iteration {
|
||||
/* 二重 for ループ */
|
||||
static String nestedForLoop(int n) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
// i = 1, 2, ..., n-1, n とループする
|
||||
// i = 1, 2, ..., n-1, n のループ
|
||||
for (int i = 1; i <= n; i++) {
|
||||
// j = 1, 2, ..., n-1, n とループする
|
||||
// j = 1, 2, ..., n-1, n のループ
|
||||
for (int j = 1; j <= n; j++) {
|
||||
res.append("(" + i + ", " + j + "), ");
|
||||
}
|
||||
@@ -56,19 +56,19 @@ public class iteration {
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
/* 実行用コード */
|
||||
public static void main(String[] args) {
|
||||
int n = 5;
|
||||
int res;
|
||||
|
||||
res = forLoop(n);
|
||||
System.out.println("\nfor ループの合計結果 res = " + res);
|
||||
System.out.println("\nfor ループで求めた和 res = " + res);
|
||||
|
||||
res = whileLoop(n);
|
||||
System.out.println("\nwhile ループの合計結果 res = " + res);
|
||||
System.out.println("\nwhile ループで求めた和 res = " + res);
|
||||
|
||||
res = whileLoopII(n);
|
||||
System.out.println("\nwhile ループ(2 回更新)の合計結果 res = " + res);
|
||||
System.out.println("\nwhile ループ(2 回の更新)で求めた和 res = " + res);
|
||||
|
||||
String resStr = nestedForLoop(n);
|
||||
System.out.println("\n二重 for ループの走査結果 " + resStr);
|
||||
|
||||
Reference in New Issue
Block a user