PawelG: Różnice pomiędzy wersjami
Z Lem
| Linia 3: | Linia 3: | ||
# Czy potrafisz je udowodnić? | # Czy potrafisz je udowodnić? | ||
| − | + | ||
| − | + | '''program''' PawelG;\ \ (* autor Paweł Gburzyński, 1983, \cite{Zabo83}\ \ *) | |
| − | + | '''var''' A: '''arrayof''' integer; | |
| − | + | '''var''' n, k, j, licz: integer ; | |
| − | var A: arrayof integer; | + | '''unit''' DrukujA: '''procedure'''; |
| − | + | '''var''' j: integer | |
| − | var n, k, j, licz: integer ; | + | '''begin''' |
| − | unit DrukujA: | + | writeln |
| − | var j: integer | + | '''end''' DrukujA; |
| − | + | '''unit''' F: \textbf{'''procedure'''}; | |
| − | + | '''var''' i: integer; | |
| − | writeln | + | \textbf{'''begin'''} |
| − | + | \textbf{if} k=n+1 \textbf{then} | |
| − | + | \textbf{call} DrukujA; \ licz := licz+1 | |
| − | + | \textbf{else} | |
| − | var i: integer; | + | \textbf{for} i:= 1 \textbf{to} n |
| − | \textbf{begin} | + | \textbf{do} |
| − | \textbf{if} k=n+1 \textbf{then} | + | \textbf{if} A[i]=0 \textbf{then} |
| − | \textbf{call} DrukujA; \ licz := licz+1 | + | A[i] := k; k := k+1; |
| − | \textbf{else} | + | \textbf{call} F; |
| − | \textbf{for} i:= 1 \textbf{to} n | + | k := k-1; A[i]:=0 |
| − | \textbf{do} | + | \textbf{fi}; |
| − | \textbf{if} A[i]=0 \textbf{then} | + | \textbf{od}; |
| − | A[i] := k; k := k+1; | + | \textbf{fi};\ \ \textbf{return} |
| − | \textbf{call} F; | + | \textbf{end} F; |
| − | k := k-1; A[i]:=0 | + | '''begin''' |
| − | \textbf{fi}; | + | readln(n); |
| − | \textbf{od}; | + | array A dim(1:n); |
| − | \textbf{fi};\ \ \textbf{return} | + | '''for''' j := 1 '''to''' n '''do''' A[j] := 0 '''od'''; |
| − | \textbf{end} F; | + | k :=1; |
| − | + | licz:=0; | |
| − | readln(n); | + | '''call''' F; |
| − | array A dim(1:n); | + | writeln(''Bywaj``) |
| − | + | '''end''' PawelG | |
| − | + | ||
| − | k :=1; | + | |
| − | + | ||
| − | writeln(''Bywaj``) | + | |
| − | + | ||
| − | + | ||
| − | + | ||
Wersja z 10:54, 16 mar 2020
Poniżej znajdziesz niewielki program.
- Czy potrafisz odgadnąc co ten program robi i sformułować odpowiednie twierdzenie?
- Czy potrafisz je udowodnić?
program PawelG;\ \ (* autor Paweł Gburzyński, 1983, \cite{Zabo83}\ \ *)
var A: arrayof integer;
var n, k, j, licz: integer ;
unit DrukujA: procedure;
var j: integer
begin
writeln
end DrukujA;
unit F: \textbf{procedure};
var i: integer;
\textbf{begin}
\textbf{if} k=n+1 \textbf{then}
\textbf{call} DrukujA; \ licz := licz+1
\textbf{else}
\textbf{for} i:= 1 \textbf{to} n
\textbf{do}
\textbf{if} A[i]=0 \textbf{then}
A[i] := k; k := k+1;
\textbf{call} F;
k := k-1; A[i]:=0
\textbf{fi};
\textbf{od};
\textbf{fi};\ \ \textbf{return}
\textbf{end} F;
begin
readln(n); array A dim(1:n); for j := 1 to n do A[j] := 0 od; k :=1; licz:=0; call F; writeln(Bywaj``)
end PawelG