1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
program TrianglePascal;
uses Flash8;
{$FRAME_WIDTH 1200}
{$FRAME_HEIGHT 600}
{$BACKGROUND 0}
const
LARGEUR = 1200;
HAUTEUR = 600;
VER = 'Compilateur FlashPascal 2 v14.04.22'#13;
var
t: TextField;
f: TextFormat;
s: string;
function IntToLStr(i, l: integer; char: string): string;
begin
result := IntToStr(i);
while length(result) < l do
result := char + result;
end;
const
N = 17;
var
tr: array[1..N, 1..N]of integer;
procedure Calcule(const aX, aY: integer);
begin
if aX + aY <= N + 1 then
begin
tr[aX, aY] := tr[aX - 1, aY] + tr[aX, aY - 1];
Calcule(aX, aY + 1);
Calcule(aX + 1, aY);
end;
end;
var
x, y: integer;
begin
f := TextFormat.Create('Courier New', 16);
f.color := clWhite;
f.leftMargin := 5;
t := TextField.Create(_root, 't', 0, 0, 0, LARGEUR, HAUTEUR);
t.SetNewTextFormat(f);
for x := 1 to N do
tr[x, 1] := 1;
for y := 1 to N do
tr[1, y] := 1;
Calcule(2, 2);
s := '';
for y := 1 to N do
begin
for x := 1 to N do
if x + y <= N + 1 then
s := s + IntToLStr(tr[x, y], 6, ' ');
s := s + #13;
end;
t.text := VER + s;
f.size := 12;
f.color := clLime;
t.SetTextFormat(0, Length(VER) - 1, f);
end. |
Partager