Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils,
  7. Math;
  8.  
  9. function Fact(N: Integer): Integer;
  10. begin
  11. if N < 0 then Result := -1
  12. else if N = 0 then Result := 1
  13. else Result := N * Fact(N-1);
  14. end;
  15.  
  16. function GetUniqueChars(S: String): String;
  17. var
  18. UniqueChars: array of Char;
  19. CS: Integer;
  20. begin
  21. if Length(S) > 1 then
  22. begin
  23. UniqueChars := '';
  24.  
  25. for CS := 1 to Length(S) do
  26. {TODO}
  27. end
  28. else
  29. UniqueChars := S;
  30.  
  31. Result := UniqueChars;
  32. end;
  33.  
  34. var
  35. N: Integer;
  36. S: String;
  37.  
  38. begin
  39. try
  40. {$I-}
  41. Readln(N);
  42. {$I+}
  43.  
  44. if IOResult <> 0 then
  45. begin
  46. Writeln('Error! Please enter something more understandable next time...');
  47. Readln;
  48. Exit;
  49. end;
  50.  
  51. N := Fact(N);
  52.  
  53. if N = -1 then
  54. begin
  55.  
  56. Writeln(
  57. 'The correct value for the factorial function ' +
  58. 'is a non-negative integer.'
  59. );
  60.  
  61. Readln;
  62. Exit;
  63.  
  64. end;
  65.  
  66. if N <= 0 then
  67. begin
  68. Writeln('Out of Boundaries Error!');
  69. Readln;
  70. Exit;
  71. end;
  72.  
  73. S := IntToStr(N);
  74. //S := GetUniqueChars(S);
  75. Writeln(S);
  76. Readln;
  77. except
  78. raise;
  79. end;
  80. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement