ウィキのコピーミラー

これは pascal.chat のウィキのミラーです。編集、履歴、ログインはそちらで行います。

Basic Pascal Tutorial/Chapter 5/Multidimensional arrays/ja

English · Français · Български · 中文(中国) · 日本語

5D - 多次元配列 (著者: Tao Yue, 状態: 原文のまま変更なし)

多次元の配列を扱うこともできる。

pascal
type
  datatype = array [enum_type1, enum_type2] of datatype;

カンマで次元を分け、配列は次のように示せる。

pascal
a [5, 3]

2次元配列はボードゲームをプログラミングするときに役立つ。3目並べのボードでは以下のタイプと変数宣言をする。

pascal
type
  StatusType = (X, O, Blank);
  BoardType = array[1..3,1..3] of StatusType;
var
  Board : BoardType;

ボードは次のように初期化できる。

pascal
for count1 := 1 to 3 do
  for count2 := 1 to 3 do
    Board[count1, count2] := Blank;

もちろん、3次元やさらに高次の配列も利用できる。

previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Multidimensional arrays/ja", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

第1版、最終更新:WikiArchive 。