SHARE
TWEET

Untitled

a guest Oct 15th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program laba2_2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8.   System.SysUtils;
  9.  
  10. type MyArr = array of Integer;
  11.  
  12. function EnterValue(Num: Integer) : Integer;
  13.   begin
  14.     try
  15.       Readln(Num);
  16.     except
  17.       Writeln('Error, try again');
  18.       EnterValue := EnterValue(Num);
  19.     end;
  20.     EnterValue := Num;
  21.   end;
  22.  
  23.   function CheckValue(Max, Min, Num: Integer) : Boolean;
  24.   begin
  25.     if (Max < Num) or (Num < Min) then
  26.     begin
  27.       Writeln('Ur value is not belongs[' , Min , ' ; ' , Max , ']');
  28.       CheckValue := False;
  29.     end;
  30.     CheckValue := True;
  31.   end;
  32.  
  33.   function EnterCheckValue(Max, Min, Num: Integer; msg: String) : Integer;
  34.   begin
  35.     repeat
  36.       Writeln(msg);
  37.       Num := EnterValue(Num)
  38.     until(CheckValue(Max, Min, Num));
  39.     EnterCheckValue := Num;
  40.   end;
  41.  
  42.   function CheckCapacity(Num: Extended) : Integer;
  43.   var
  44.     i: Integer;
  45.   begin
  46.     i := 1;
  47.     repeat
  48.       Num := Num / 10;
  49.       Inc(i);
  50.     until(Num / 10 = 0);
  51.     CheckCapacity := i;
  52.   end;
  53.  
  54.   function BitComperison(Num1, Num2: Integer) : Boolean;
  55.   begin
  56.     if CheckCapacity(Num1) <> CheckCapacity(Num2) then
  57.     begin
  58.       Writeln('Not eq');
  59.       BitComperison := False;
  60.     end;
  61.     BitComperison := True;
  62.   end;
  63.  
  64.   function ArraySplit(Arr: MyArr; Num: Integer): MyArr;
  65.   var
  66.     i: Integer;
  67.   begin
  68.     for i := 0 to High(Arr) - 1 do
  69.     begin
  70.       Arr[i] := Num mod 10;
  71.       Num := Num div 10;
  72.       ArraySplit := Arr;
  73.     end;
  74.  
  75.   end;
  76.  
  77.   procedure PrintArray(Msg: String; Arr: array of Integer);
  78.   var
  79.     i: Integer;
  80.   begin
  81.     Writeln(Msg);
  82.     for i := High(Arr) - 1 to 0 do
  83.     begin
  84.       if i <> High(Arr) - 1 then
  85.         Writeln(', ');
  86.         Writeln(Arr[i]);
  87.     end;
  88.   end;
  89.  
  90. var
  91.   FirstNum, SecondNum, i, MaxValue, MinValue: Integer;
  92.   IsCorrect: Boolean;
  93.   ArrOf1, ArrOf2: MyArr;
  94. begin
  95.   MaxValue := 9999999;
  96.   MinValue := 100;
  97.   repeat
  98.     FirstNum := EnterCheckValue(MaxValue, MinValue, FirstNum, 'Enter first num');
  99.     SecondNum := EnterCheckValue(MaxValue, MinValue, SecondNum, 'Enter second num');
  100.     IsCorrect := BitComperison(FirstNum, SecondNum);
  101.   until (IsCorrect);
  102.   SetLength(ArrOf1, CheckCapacity(FirstNum));
  103.   SetLength(ArrOf2, CheckCapacity(SecondNum));
  104.   ArrOf1 := ArraySplit(ArrOf1, FirstNum);
  105.   ArrOf2 := ArraySplit(ArrOf2, FirstNum);
  106.   for i := 0 to High(ArrOf1) - 1 do
  107.   begin
  108.     ArrOf1[i] := ArrOf1[i] - ArrOf2[i];
  109.   end;
  110.   for i := 0 to 5 do
  111.     Writeln(ArrOf1[1]);
  112.   readln;
  113. 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