You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// spodziewany wynik to 3! i taki podaje Free Pascal
uses crt;
const
size = 2; // od zera to size+1 elementow
var
board : array [0..size] of byte;
i : byte;
counter : word = 0;
procedure generate(n: byte);
var
i, tmp: byte;
begin
if n = 0 then
begin
//for tmp in board do write(tmp); writeln;
inc(counter);
end
else
begin
for i := 0 to n do begin
tmp := board[i]; board[i] := board[n]; board[n] := tmp;
generate(n-1);
tmp := board[i]; board[i] := board[n]; board[n] := tmp;
end;
end;
end;
begin
for i := 0 to size do board[i] := i;
generate(size);
writeln('liczba permutacji: ', counter);
repeat until keypressed;
end.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: