uses GraphABC;
var
x, y, a: integer;
procedure treug(x, y, a, b: integer);
begin
x := 0;
y := 20;
line(x, y, x+a, y);
line(x, y, x, y+b);
line(x+a, y, x, y+b);
end;
begin
writeln('Enter the length of the catheter');
read(a);
while y < 480 do
begin
y := y+1;
treug(x, y, a, a);
end;
end.
Outputs only one triangle, and not the desired number up to the vertical border.
I expected one vertical row of right triangles (x and y are the coordinates of the right angle) to the lower border of the graphic window.
Remember, you have two sets
xandyvariables:treug()procedure.Things may have the same name and not be the same thing. If it helps, you can think of the global
xasGraphABC.xand the localxasGraphABC.treug.x.BTW, you probably want to increment
yby something more than1each time through the loop, otherwise it’ll look just like a single triangle has been smeared down the display. (You might want to increment byb.)