A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
29
Task/Man-or-boy-test/Delphi/man-or-boy-test.delphi
Normal file
29
Task/Man-or-boy-test/Delphi/man-or-boy-test.delphi
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
type
|
||||
TFunc<T> = reference to function: T;
|
||||
|
||||
function C(x: Integer): TFunc<Integer>;
|
||||
begin
|
||||
Result := function: Integer
|
||||
begin
|
||||
Result := x;
|
||||
end;
|
||||
end;
|
||||
|
||||
function A(k: Integer; x1, x2, x3, x4, x5: TFunc<Integer>): Integer;
|
||||
var
|
||||
b: TFunc<Integer>;
|
||||
begin
|
||||
b := function: Integer
|
||||
begin
|
||||
Dec(k);
|
||||
Result := A(k, b, x1, x2, x3, x4);
|
||||
end;
|
||||
if k <= 0 then
|
||||
Result := x4 + x5
|
||||
else
|
||||
Result := b;
|
||||
end;
|
||||
|
||||
begin
|
||||
Writeln(A(10, C(1), C(-1), C(-1), C(1), C(0))); // -67 output
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue