klasscho

Untitled

Oct 28th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Program Project6;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. sysUtils;
  7. function CheckOne(max : integer) : integer;
  8. var
  9. IsCorrect: Boolean;
  10. input: integer;
  11. begin
  12. repeat
  13. try
  14. writeln('Enter a value : ');
  15. readln(input);
  16. if ((input > 0) and (input < max)) then
  17. IsCorrect := True
  18. else
  19. writeln('Enter a correct value!');
  20. except
  21. IsCorrect := False;
  22. writeln ('Try again. Enter a correct value!');
  23. end;
  24. until IsCorrect;
  25. end;
  26.  
  27. function drob() : integer;
  28. var
  29. proizv, chisl, znam: integer;
  30. begin
  31. proizv := chisl * znam;
  32. drob := proizv;
  33. end;
  34.  
  35. function CheckTwo() : integer;
  36. var
  37. chisl, znam, l: integer;
  38. begin
  39. if (chisl < znam) then
  40. for l := chisl downto 2 do
  41. if (chisl mod l = 0) and (znam mod l = 0) then
  42. chisl := chisl div l;
  43. znam := znam div l;
  44. end;
  45. const
  46. MaxInt = 46340;
  47. var
  48. m, n, p, q, a, b, chisl1, znam1 : integer;
  49. begin
  50. Writeln ('This program divides two irreducible fractions');
  51. m := CheckOne(MaxInt);
  52. n := CheckOne(MaxInt);
  53. p := CheckOne(MaxInt);
  54. q := CheckOne(MaxInt);
  55. a := CheckTwo;
  56. b := CheckTwo;
  57. chisl1 := drob;
  58. znam1 := drob;
  59. writeln (chisl1 ,'/', znam1);
  60. readln;
  61. end.
Advertisement
Add Comment
Please, Sign In to add comment