Skip to content

Instantly share code, notes, and snippets.

@eugeneai
Created May 19, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugeneai/576115d1923822e4035b to your computer and use it in GitHub Desktop.
Save eugeneai/576115d1923822e4035b to your computer and use it in GitHub Desktop.
recursion with sand watch
program lab_10;
uses crt;
const
n=60;
m=16;
var
l,i,a,j,k:integer;
procedure picture1(a,l,t:integer);
begin
if t>0 then
begin
write(' ');
picture1(a,l,t-1);
end
else
begin
write(chr(a+65),chr(a+65));
if l>0 then
begin
l:=l-1;
picture1(a,l,0);
end;
end;
end;
procedure sand_watch(a,e,t:integer);
begin
if a=e then
begin
picture1(a,a,t); writeln;
end
else
begin
picture1(a,e,t);
picture1(a,e,t); writeln;
sand_watch(a-1,e,t+1);
picture1(a,e,t);
picture1(a,e,t); writeln;
end;
end;
begin
sand_watch(10,1,0);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment