tnest4.pp 765 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {$mode objfpc}
  2. function test: longint;
  3. function func(aa: integer): integer;
  4. function func_nested(b: integer): integer;
  5. begin
  6. if b < 10 then
  7. Result:=func_nested(b+1)
  8. else
  9. Result:=b;
  10. Inc(Result, aa);
  11. end;
  12. begin
  13. Result:=func_nested(0);
  14. end;
  15. begin
  16. result:=func(10);
  17. end;
  18. function test2: longint;
  19. var
  20. i: integer;
  21. function func(aa: integer): integer;
  22. function func_nested(b: integer): integer;
  23. begin
  24. if b < 10 then
  25. Result:=func(b+1)
  26. else
  27. Result:=b;
  28. end;
  29. begin
  30. Result:=func_nested(aa);
  31. Inc(Result, i);
  32. end;
  33. begin
  34. i:=100;
  35. result:=func(0);
  36. end;
  37. begin
  38. if test <> 120 then
  39. halt(1);
  40. if test2 <> 1110 then
  41. halt(2);
  42. writeln('OK');
  43. end.