维基副本镜像

这是 pascal.chat 维基的镜像。编辑、历史记录和登录都在那里。

Basic Pascal Tutorial/Chapter 5/Multidimensional arrays/zh CN

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

5D - 多维数组 (原作者: Tao Yue, 状态: 未更改)

你可以定义多维数组:

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

下标间用逗号分隔:

pascal
a [5, 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;

当然,你也可以使用三维或更多维的数组。

上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Multidimensional arrays/zh CN", 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于修改。