SHARE
TWEET

Untitled

a guest Oct 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project5;
  2. uses
  3.    System.SysUtils;
  4. type TIntegerArray = array of Integer;
  5.      TDoubleArray = array of Double;
  6.  
  7. function NumberCheck(): Integer;
  8. var
  9.    IsCorrect: Boolean;
  10.    Number: Integer;
  11.  
  12. begin
  13.    IsCorrect := false;
  14.    repeat
  15.       try
  16.          Readln(Number);
  17.          IsCorrect := true;
  18.       except
  19.          Writeln('Validation: Entered value is no integer');
  20.       end;
  21.    until IsCorrect;
  22.    NumberCheck := Number;
  23. end;
  24.  
  25. function RangeCheck(Max, Min, Num: integer ): Boolean;
  26. var
  27.    IsCorrect: Boolean;
  28. begin
  29.    IsCorrect := false;
  30.    if (Max < Num) and (Num < Min) then
  31.       IsCorrect := false
  32.    else
  33.       IsCorrect := true ;
  34.    RangeCheck := IsCorrect;
  35. end;
  36.  
  37. procedure ArrOut(Msg: String; DoubleArray: TDoubleArray);
  38. var
  39.    i, temp: Integer;
  40. begin
  41.    Writeln(Msg);
  42.    for i := (High(DoubleArray)) downto 0 do
  43.       if i = 0 then
  44.          Write(DoubleArray[i] : 3 : 2)
  45.       else
  46.          Write(DoubleArray[i] : 3 : 2, ', ');
  47. end;
  48.  
  49. function EnterCheckValue(Max ,Min , Num: Integer; Msg: String): Integer;
  50. var
  51.    SsCorrect: Boolean;
  52. begin
  53.    Writeln(Msg);
  54.    repeat
  55.       Num := NumberCheck();
  56.    until RangeCheck(Max, Min, Num);
  57.    EnterCheckValue := Num;
  58. end;
  59.  
  60. function Division(Num: Integer): Integer;
  61. var
  62.    i: Integer;
  63. begin
  64.    i := 1;
  65.    while (Num div 10 <> 0) do
  66.    begin
  67.       Num := Num mod 10;
  68.       i := i + 1;
  69.    end;
  70.    Result := i;
  71. end;
  72.  
  73. function BitComparison(Num1, Num2: Integer): Boolean;
  74. var
  75.    IsCorrect: Boolean;
  76. begin
  77.    if (Division(Num1) <> Division(Num2)) then
  78.    begin
  79.       Writeln('Digit capacity is not equal, try again');
  80.       IsCorrect := false;
  81.    end;
  82.    IsCorrect := true;
  83.    BitComparison := IsCorrect;
  84. end;
  85.  
  86. function ArraySplit(DoubleArray: TIntegerArray; Num: Integer): TIntegerArray;
  87. var
  88.    i: Integer;
  89. begin
  90.    for i := 0 to High(DoubleArray) do
  91.    begin
  92.       DoubleArray[i]:= Num mod 10;
  93.       Num := Num div 10;
  94.    end;
  95.    Result := DoubleArray;
  96. end;
  97.  
  98. procedure Main();
  99. var
  100.    i, FirstNum, SecondNum : Integer;
  101.    ArrOf1: TIntegerArray;
  102.    ArrOf2: TIntegerArray;
  103.    ArrOf3: TDoubleArray;
  104.    IsCorrect: Boolean;
  105. const
  106.   MaxValue = 9999999;
  107.   MinValue = 100;
  108.  
  109. begin
  110.    repeat
  111.       FirstNum := EnterCheckValue(MaxValue, MinValue, FirstNum, 'Enter first num');
  112.       SecondNum := EnterCheckValue(MaxValue, MinValue, SecondNum, 'Enter second num');
  113.    until BitComparison(FirstNum, SecondNum);
  114.    SetLength(ArrOf1,Division(FirstNum) + 1);
  115.    SetLength(ArrOf2,Division(SecondNum) + 1);
  116.    SetLength(ArrOf3,Division(SecondNum) + 1);
  117.    ArrOf1 := ArraySplit(ArrOf1, FirstNum);
  118.    ArrOf2 := ArraySplit(ArrOf2, SecondNum);
  119.    for i := 0 to (length(ArrOf3) - 1) do
  120.    begin
  121.       ArrOf3[i] := ArrOf1[i] / ArrOf2[i];
  122.    end;
  123.    ArrOut('Final array', ArrOf3);
  124.    Readln;
  125. end;
  126. begin
  127.    Main();
  128.    Readln;
  129. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top