開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- C++ (プログラミング言語)
- g++(コンパイラ(Unix CCコンパイラ (汎用Unix)だと上手くいかなかったからとりあえず。))
C++実践プログラミング (スティーブ オウアルライン (著)、Steve Oualline (原著)、Steve Oualline(原著)、望月 康司(翻訳)、クイープ(翻訳) 、オライリー・ジャパン)のⅠ部(基礎)の5章(配列、修飾子、数値の使用)、5.5(多次元配列)、設問5-2.を解いてみる。
その他参考書籍
- C++プログラミング入門 (グレゴリー サティア (著)、ダウグ ブラウン (著)、Gregory Satir (原著)、Doug Brown (原著)、望月 康司 (翻訳)、谷口 功 (翻訳)、オライリージャパン)
設問5-2.
コード
sample.cpp
#include <iostream>
int array[3][5] = {
{0, 1, 2, 3, 4},
{10, 11, 12, 13, 14},
{20, 21, 22, 23, 24}
};
int main()
{
/* C++の多次元配列は、array[,]ではなくarray[][] */
std::cout << "Last element is " << array[2][4] << '\n';
return (0);
}
入出力結果(Terminal)
$ g++ -g -Wall -osample sample.cpp $ ./sample Last element is 24 $
0 コメント:
コメントを投稿