Advertisement
fatalryuu

laba

Sep 15th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.01 KB | None | 0 0
  1. program laba1;
  2.  
  3. uses System.Sysutils;
  4. const MIN_COORD = -100;
  5.       MAX_COORD = 100;
  6. var
  7.     X1, Y1, X2, Y2, DotX, DotY: Integer;
  8.     IsCorrect: Boolean;
  9. begin
  10.     Writeln('This program determines if the point with the given coordinates');
  11.     Writeln('belongs to the area of the rectangle.');
  12.     repeat
  13.         IsCorrect := True;
  14.         repeat
  15.             IsCorrect := True;
  16.             Writeln('Enter the first x coordinate(-100; 100): ');
  17.             try
  18.                 Readln (X1);
  19.             except
  20.                 Writeln('That not a number!');
  21.                 IsCorrect := False;
  22.             end;
  23.             if (IsCorrect and ((X1 > MAX_COORD) or (X1 < MIN_COORD))) then
  24.             begin
  25.                 Writeln('Please, enter a coordinate between -100 and 100.');
  26.                 IsCorrect := False
  27.             end;
  28.         until (IsCorrect);
  29.  
  30.         repeat
  31.             IsCorrect := True;
  32.             Writeln('Enter the first y coordinate(-100; 100): ');
  33.             try
  34.                 Readln (Y1);
  35.             except
  36.                 Writeln('That not a number!');
  37.                 IsCorrect := False;
  38.             end;
  39.             if (IsCorrect and ((Y1 > MAX_COORD) or (Y1 < MIN_COORD))) then
  40.             begin
  41.                 Writeln('Please, enter a coordinate between -100 and 100.');
  42.                 IsCorrect := False
  43.             end;
  44.         until (IsCorrect);
  45.  
  46.         repeat
  47.             IsCorrect := True;
  48.             Writeln('Enter the second x coordinate(-100; 100): ');
  49.             try
  50.                 Readln (X2);
  51.             except
  52.                 Writeln('That not a number!');
  53.                 IsCorrect := False;
  54.             end;
  55.             if (IsCorrect and ((X2 > MAX_COORD) or (X2 < MIN_COORD))) then
  56.             begin
  57.                 Writeln('Please, enter a coordinate between -100 and 100.');
  58.                 IsCorrect := False
  59.             end;
  60.         until (IsCorrect);
  61.  
  62.         repeat
  63.             IsCorrect := True;
  64.             Writeln('Enter the second y coordinate(-100; 100): ');
  65.             try
  66.                 Readln (Y2);
  67.             except
  68.                 Writeln('That not a number!');
  69.                 IsCorrect := False;
  70.             end;
  71.             if (IsCorrect and ((Y2 > MAX_COORD) or (Y2 < MIN_COORD))) then
  72.             begin
  73.                 Writeln('Please, enter a coordinate between -100 and 100.');
  74.                 IsCorrect := False
  75.             end;
  76.         until (IsCorrect);
  77.         if ((X1 = X2) or (Y1 = Y2)) then
  78.         begin
  79.             Writeln('Please try the different coordinates!');
  80.             IsCorrect := False;
  81.         end;
  82.     until (IsCorrect);
  83.     repeat
  84.         IsCorrect := True;
  85.         Writeln('Enter x coordinate of the dot(-100; 100): ');
  86.         try
  87.             Readln (DotX);
  88.         except
  89.             Writeln('That not a number!');
  90.             IsCorrect := False;
  91.         end;
  92.         if (IsCorrect and ((DotX > MAX_COORD) or (DotX < MIN_COORD))) then
  93.         begin
  94.             Writeln('Please, enter a coordinate between -100 and 100.');
  95.             IsCorrect := False
  96.         end;
  97.     until (IsCorrect);
  98.  
  99.     repeat
  100.         IsCorrect := True;
  101.         Writeln('Enter y coordinate of the dot(-100; 100): ');
  102.         try
  103.             Readln (DotY);
  104.         except
  105.             Writeln('That not a number!');
  106.             IsCorrect := False;
  107.         end;
  108.         if (IsCorrect and ((DotY > MAX_COORD) or (DotY < MIN_COORD))) then
  109.         begin
  110.             Writeln('Please, enter a coordinate between -100 and 100.');
  111.             IsCorrect := False
  112.         end;
  113.     until (IsCorrect);
  114.  
  115.     Inc(X1);
  116.     Inc(X2);
  117.     Inc(Y1);
  118.     Inc(Y2);
  119.  
  120.     if ((DotX > X1) and (DotX < X2)) or ((DotX < X1) and (DotX > X2)) then
  121.     begin
  122.         if ((DotY > Y1) and (DotY < Y2) or (DotY < Y1) and (DotY > Y2)) then
  123.             Writeln('Belongs to rectangle!')
  124.         else
  125.             Writeln('Does not belong to rectangle!')
  126.     end
  127.     else
  128.         Writeln('Does not belong to rectangle!');
  129.     Readln;
  130. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement