program words;
uses crt;
type
T2DArray = array[1..100, 1..100] of string;
var
ch:char;
x,y:integer;
MapArray: T2DArray;
begin
x:=0;
y:=0;
repeat
MapArray[10, 10] := 'you are at a tree';
writeln(MapArray[x,y]);
write('current positon is ');
write(x);write(',');write(y);
ch:=ReadKey;
case ch of
#0 : begin
ch:=ReadKey; {Read ScanCode}
case ch of
'w' : y:=y+1;
'a' : x:=x-1;
's' : y:=y-1;
'd' : x:=x+1;
end;
end;
#27 : WriteLn('ESC');
end;
until ch=#27;
readln;
end.
我有这段简单的代码,可以让我将事物分配给二维数组的 XY 坐标。尽管有 readln,代码仍会立即编译并关闭;在底部。一切顺利,阿兰。