mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-09 23:40:05 +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:
@@ -9,7 +9,7 @@
|
||||
/* for ループ */
|
||||
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;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ int forLoop(int n) {
|
||||
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++; // 条件変数を更新する
|
||||
@@ -28,11 +28,11 @@ int whileLoop(int n) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* while ループ(2回更新) */
|
||||
/* while ループ(2 回の更新) */
|
||||
int whileLoopII(int n) {
|
||||
int res = 0;
|
||||
int i = 1; // 条件変数を初期化する
|
||||
// 1, 4, 10, ... を順に加算する
|
||||
// ループで 1, 4, 10, ... の和を求める
|
||||
while (i <= n) {
|
||||
res += i;
|
||||
// 条件変数を更新する
|
||||
@@ -45,9 +45,9 @@ int whileLoopII(int n) {
|
||||
/* 二重 for ループ */
|
||||
string nestedForLoop(int n) {
|
||||
ostringstream res;
|
||||
// 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 << "(" << i << ", " << j << "), ";
|
||||
}
|
||||
@@ -55,19 +55,19 @@ string nestedForLoop(int n) {
|
||||
return res.str();
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
/* 実行用コード */
|
||||
int main() {
|
||||
int n = 5;
|
||||
int res;
|
||||
|
||||
res = forLoop(n);
|
||||
cout << "\nfor ループの合計結果 res = " << res << endl;
|
||||
cout << "\nfor ループで求めた和 res = " << res << endl;
|
||||
|
||||
res = whileLoop(n);
|
||||
cout << "\nwhile ループの合計結果 res = " << res << endl;
|
||||
cout << "\nwhile ループで求めた和 res = " << res << endl;
|
||||
|
||||
res = whileLoopII(n);
|
||||
cout << "\nwhile ループ(2 回更新)の合計結果 res = " << res << endl;
|
||||
cout << "\nwhile ループ(2 回の更新)で求めた和 res = " << res << endl;
|
||||
|
||||
string resStr = nestedForLoop(n);
|
||||
cout << "\n二重 for ループの走査結果 " << resStr << endl;
|
||||
|
||||
Reference in New Issue
Block a user