Created
February 19, 2019 13:15
-
-
Save KeitetsuWorks/98a188c1fa93468f872bb448962388a1 to your computer and use it in GitHub Desktop.
複数の点数を順番に出力する (3次元配列)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 処理名 点数出力 [Lesson43-3.c] | |
| * 処理概要 複数の点数を順番に出力する (3次元配列) | |
| * 更新履歴 | |
| * Ver1.00.000 20xx/10/01 David Stevenson 新規作成 | |
| */ | |
| #include <stdio.h> | |
| int main(void) | |
| { | |
| /* 出力する数字を格納 */ | |
| int iOutput[2][3][4] = { | |
| { | |
| { 111, 112, 113, 114 }, | |
| { 121, 122, 123 } | |
| } | |
| }; /* C will initialize the extra elements to 0. */ | |
| int iCnt1, iCnt2, iCnt3; /* ループカウンタ */ | |
| /* iCnt1が2になるまでの処理 */ | |
| for (iCnt1 = 0; iCnt1 < 2; iCnt1++) { | |
| /* iCnt2が3になるまでの処理 */ | |
| for (iCnt2 = 0; iCnt2 < 3; iCnt2++) { | |
| /* iCnt3が4になるまでの処理 */ | |
| for (iCnt3 = 0; iCnt3 < 4; iCnt3++) { | |
| printf("要素[%d][%d][%d] = %d\n", iCnt1, iCnt2, iCnt3, iOutput[iCnt1][iCnt2][iCnt3]); | |
| } | |
| } | |
| } | |
| /* | |
| * <完成したプログラムの動作確認> | |
| * 1. 要素[0][0][0]の表示結果が111であること。 | |
| * 2. 要素[0][0][1]の表示結果が112であること。 | |
| * 3. 要素[0][1][0]の表示結果が121であること。 | |
| * 4. 要素[0][1][1]の表示結果が122であること。 | |
| */ | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment