delphi 數(shù)組與子界
來源:教育資源網(wǎng)
?
發(fā)布時(shí)間:2021-05-13 14:57:31
?
點(diǎn)擊:48
數(shù)組與子界
type
TABC = 'A'..'G'; {定義子界}
var
abcArr: array[TABC] of Integer; {定義數(shù)組}
abc: TABC; {定義子界變量}
begin
{數(shù)組賦值}
abcArr['A'] := 11;
abcArr['B'] := 22;
abcArr['C'] := 33;
abcArr['D'] := 44;
abcArr['E'] := 55;
abcArr['F'] := 66;
abcArr['G'] := 77;
{調(diào)用數(shù)組}
ShowMessage(IntToStr(abcArr['G'])); {77}
{遍歷數(shù)組}
for abc := Low(abcArr) to High(abcArr) do
begin
ShowMessage(IntToStr(abcArr[abc])); {11 22 33 44 55 66 77}
end;
end;
type
TABC = 'A'..'G'; {定義子界}
var
abcArr: array[TABC] of Integer; {定義數(shù)組}
abc: TABC; {定義子界變量}
begin
{數(shù)組賦值}
abcArr['A'] := 11;
abcArr['B'] := 22;
abcArr['C'] := 33;
abcArr['D'] := 44;
abcArr['E'] := 55;
abcArr['F'] := 66;
abcArr['G'] := 77;
{調(diào)用數(shù)組}
ShowMessage(IntToStr(abcArr['G'])); {77}
{遍歷數(shù)組}
for abc := Low(abcArr) to High(abcArr) do
begin
ShowMessage(IntToStr(abcArr[abc])); {11 22 33 44 55 66 77}
end;
end;