|
发表于 2004-8-7 12:55:00
|
显示全部楼层
Re:游戏编程精粹3的代码运行结果
用delphi写的一个,翻译的代码,但还是有问题,图形差不多了
procedure puts(s: string);
begin
memo1.lines.Text := memo1.lines.text + s;
end;
procedure ps(s: string; idx: integer);
begin
memo1.lines.text := memo1.lines.Text + s[idx];
end;
(*
#include <iostream>
using namespace std;
void main(int k)
{
float i, j, r, x, y = - 16;
while (puts(" "), y++ < 15)
for (x = 0;
x++ < 84;
putchar(" .:-;!/>)|&IH%*#"[k & 15])
)
for (
i = k = r = 0;
j = r * r - i * i - 2+x / 25, i = 2 * r * i + y / 10, j *j + i * i < 11 && k++ < 111;
r = j
)
;
}
*)
var
i, j, r, y : double; //=-16;
x : Integer;
k : Integer;
s : string;
begin
AllocConsole;
i := -16;
j := -16;
r := -16;
x := -16;
y := -16;
k := 0;
s := '.:-;!/>)|&IH%*#';
try
Write(' ');
puts(' ');
while y < 15 do
begin
y := y + 1;
puts(' '+#13);
Write(' '+#13);
x := 0;
while (x + 1) < 84 do
begin
x := x + 1;
ps('.:-;!/>)|&IH%*#', k and 15);
Write(s[k and 15]);
i := 0;
k := 0;
r := 0;
j := r * r - i * i - 2 + x / 25;
i := 2 * r * i + y / 10;
while ((j * j + i * i) < 11) and ((k + 1) < 111) do
begin
j := r * r - i * i - 2 + x / 25;
i := 2 * r * i + y / 10;
r := j;
k := k + 1;
end;
end;
end;
finally
//FreeConsole;
end;
end; |
|