SHARE
TWEET

Untitled

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