Wersja 1.
program figury; uses crt; var w, k: integer; {wiersze i kolumny} f: char; {wybrana figura} i, j: integer; {iteracje} begin clrscr; repeat begin WriteLn('Wybierz figure: '); WriteLn('P: prostokat'); WriteLn('T: trojkat'); Write('C: choinka '); f:=readkey; WriteLn; end until (f='P') or (f='T') or (f='C'); Write('Podaj liczbe wierszy: '); ReadLn(w); clrscr; if(f='P') then begin Write('Podaj liczbe kolumn: '); ReadLn(k); clrscr; for i:=1 to w do begin for j:=1 to k do Write('*'); WriteLn; end; end; if(f='T') then begin for i:=1 to w do begin for j:=1 to i do Write('*'); WriteLn; end; end; if(f='C') then begin for i:=1 to w do begin for j:=w-i downto 1 do Write(' '); for j:=1 to 2*i-1 do write('*'); writeln; end; end; delay(2000); end.
Wersja 2.
program figury; uses crt; var w, k: integer; {wiersze i kolumny} f: char; {wybrana figura, kontynuacja programu} i, j: integer; {iteracje} begin repeat begin clrscr; repeat begin WriteLn('Wybierz figure:'); WriteLn('p: prostokat'); WriteLn('1: obramowanie prostokata'); WriteLn('t: trojkat'); WriteLn('2: obramowanie trojkata'); WriteLn('c: choinka '); WriteLn('3: obramowanie choinki'); f:=lowercase(readkey); end until (f='p') or (f='t') or (f='c') or (f='1') or (f='2') or (f='3'); Write('Podaj liczbe wierszy: '); ReadLn(w); clrscr; if f='p' then begin Write('Podaj liczbe kolumn: '); ReadLn(k); clrscr; for i:=1 to w do begin for j:=1 to k do Write('*'); WriteLn; end; end; if f='1' then begin Write('Podaj liczbe kolumn: '); ReadLn(k); clrscr; for i:=1 to w do begin if (i=1) or (i=w) then begin for j:=1 to k do Write('*'); WriteLn; end else begin Write('*'); for j:=2 to k-1 do Write(' '); WriteLn('*'); end; end; end; if f='t' then begin for i:=1 to w do begin for j:=1 to i do Write('*'); WriteLn; end; end; if f='2' then begin for i:=1 to w do begin if (i=1) or (i=w) then begin for j:=1 to i do Write('*'); WriteLn; end else begin Write('*'); for j:=2 to i-1 do Write(' '); WriteLn('*'); end; end; end; if f='c' then begin for i:=1 to w do begin for j:=w-i downto 1 do Write(' '); for j:=1 to 2*i-1 do write('*'); writeln; end; end; if f='3' then begin for i:=1 to w do begin for j:=w-i downto 1 do Write(' '); if (i=1) or (i=w) then begin for j:=1 to 2*i-1 do Write('*'); end else begin for j:=1 to 2*i-1 do begin if (j=1) or (j=2*i-1) then Write('*') else Write(' '); end; end; writeln; end; end; delay(2500); WriteLn; WriteLn('Kontynuowac? [t/n]'); f:=lowercase(readkey); end until f='n'; end.