Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project5;
- uses
- System.SysUtils;
- type TIntegerArray = array of Integer;
- TDoubleArray = array of Double;
- function NumberCheck(): Integer;
- var
- IsCorrect: Boolean;
- Number: Integer;
- begin
- IsCorrect := false;
- repeat
- try
- Readln(Number);
- IsCorrect := true;
- except
- Writeln('Validation: Entered value is no integer');
- end;
- until IsCorrect;
- NumberCheck := Number;
- end;
- function RangeCheck(Max, Min, Num: integer ): Boolean;
- var
- IsCorrect: Boolean;
- begin
- IsCorrect := false;
- if (Max < Num) and (Num < Min) then
- IsCorrect := false
- else
- IsCorrect := true ;
- RangeCheck := IsCorrect;
- end;
- procedure ArrOut(Msg: String; DoubleArray: TDoubleArray);
- var
- i, temp: Integer;
- begin
- Writeln(Msg);
- for i := (High(DoubleArray)) downto 0 do
- if i = 0 then
- Write(DoubleArray[i] : 3 : 2)
- else
- Write(DoubleArray[i] : 3 : 2, ', ');
- end;
- function EnterCheckValue(Max ,Min , Num: Integer; Msg: String): Integer;
- var
- SsCorrect: Boolean;
- begin
- Writeln(Msg);
- repeat
- Num := NumberCheck();
- until RangeCheck(Max, Min, Num);
- EnterCheckValue := Num;
- end;
- function Division(Num: Integer): Integer;
- var
- i: Integer;
- begin
- i := 1;
- while (Num div 10 <> 0) do
- begin
- Num := Num mod 10;
- i := i + 1;
- end;
- Result := i;
- end;
- function BitComparison(Num1, Num2: Integer): Boolean;
- var
- IsCorrect: Boolean;
- begin
- if (Division(Num1) <> Division(Num2)) then
- begin
- Writeln('Digit capacity is not equal, try again');
- IsCorrect := false;
- end;
- IsCorrect := true;
- BitComparison := IsCorrect;
- end;
- function ArraySplit(DoubleArray: TIntegerArray; Num: Integer): TIntegerArray;
- var
- i: Integer;
- begin
- for i := 0 to High(DoubleArray) do
- begin
- DoubleArray[i]:= Num mod 10;
- Num := Num div 10;
- end;
- Result := DoubleArray;
- end;
- procedure Main();
- var
- i, FirstNum, SecondNum : Integer;
- ArrOf1: TIntegerArray;
- ArrOf2: TIntegerArray;
- ArrOf3: TDoubleArray;
- IsCorrect: Boolean;
- const
- MaxValue = 9999999;
- MinValue = 100;
- begin
- repeat
- FirstNum := EnterCheckValue(MaxValue, MinValue, FirstNum, 'Enter first num');
- SecondNum := EnterCheckValue(MaxValue, MinValue, SecondNum, 'Enter second num');
- until BitComparison(FirstNum, SecondNum);
- SetLength(ArrOf1,Division(FirstNum) + 1);
- SetLength(ArrOf2,Division(SecondNum) + 1);
- SetLength(ArrOf3,Division(SecondNum) + 1);
- ArrOf1 := ArraySplit(ArrOf1, FirstNum);
- ArrOf2 := ArraySplit(ArrOf2, SecondNum);
- for i := 0 to (length(ArrOf3) - 1) do
- begin
- ArrOf3[i] := ArrOf1[i] / ArrOf2[i];
- end;
- ArrOut('Final array', ArrOf3);
- Readln;
- end;
- begin
- Main();
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement