Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Sudan-function/Delphi/sudan-function.delphi
Normal file
40
Task/Sudan-function/Delphi/sudan-function.delphi
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
function SudanFunction(N,X,Y: integer): integer;
|
||||
begin
|
||||
if n = 0 then Result:=X + Y
|
||||
else if y = 0 then Result:=X
|
||||
else Result:=SudanFunction(N - 1, SudanFunction(N, X, Y - 1), SudanFunction(N, X, Y - 1) + Y);
|
||||
end;
|
||||
|
||||
|
||||
procedure ShowSudanFunction(Memo: TMemo; N,X,Y: integer);
|
||||
begin
|
||||
Memo.Lines.Add(Format('Sudan(%d,%d,%d)=%d',[n,x,y,SudanFunction(N,X,Y)]));
|
||||
end;
|
||||
|
||||
|
||||
procedure ShowSudanFunctions(Memo: TMemo);
|
||||
var N,X,Y: integer;
|
||||
var S: string;
|
||||
begin
|
||||
for N:=0 to 1 do
|
||||
begin
|
||||
Memo.Lines.Add(Format('Sudan(%d,X,Y)',[N]));
|
||||
Memo.Lines.Add('Y/X 0 1 2 3 4 5');
|
||||
Memo.Lines.Add('----------------------------');
|
||||
for Y:=0 to 6 do
|
||||
begin
|
||||
S:=Format('%2d | ',[Y]);
|
||||
for X:=0 to 5 do
|
||||
begin
|
||||
S:=S+Format('%3d ',[SudanFunction(N,X,Y)]);
|
||||
end;
|
||||
Memo.Lines.Add(S);
|
||||
end;
|
||||
Memo.Lines.Add('');
|
||||
end;
|
||||
|
||||
ShowSudanFunction(Memo, 1, 3, 3);
|
||||
ShowSudanFunction(Memo, 2, 1, 1);
|
||||
ShowSudanFunction(Memo, 2, 2, 1);
|
||||
ShowSudanFunction(Memo, 3, 1, 1);
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue