Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program laba1;
- uses System.Sysutils;
- const MIN_COORD = -100;
- MAX_COORD = 100;
- var
- X1, Y1, X2, Y2, DotX, DotY: Integer;
- IsCorrect: Boolean;
- begin
- Writeln('This program determines if the point with the given coordinates');
- Writeln('belongs to the area of the rectangle.');
- repeat
- IsCorrect := True;
- repeat
- IsCorrect := True;
- Writeln('Enter the first x coordinate(-100; 100): ');
- try
- Readln (X1);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((X1 > MAX_COORD) or (X1 < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- repeat
- IsCorrect := True;
- Writeln('Enter the first y coordinate(-100; 100): ');
- try
- Readln (Y1);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((Y1 > MAX_COORD) or (Y1 < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- repeat
- IsCorrect := True;
- Writeln('Enter the second x coordinate(-100; 100): ');
- try
- Readln (X2);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((X2 > MAX_COORD) or (X2 < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- repeat
- IsCorrect := True;
- Writeln('Enter the second y coordinate(-100; 100): ');
- try
- Readln (Y2);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((Y2 > MAX_COORD) or (Y2 < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- if ((X1 = X2) or (Y1 = Y2)) then
- begin
- Writeln('Please try the different coordinates!');
- IsCorrect := False;
- end;
- until (IsCorrect);
- repeat
- IsCorrect := True;
- Writeln('Enter x coordinate of the dot(-100; 100): ');
- try
- Readln (DotX);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((DotX > MAX_COORD) or (DotX < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- repeat
- IsCorrect := True;
- Writeln('Enter y coordinate of the dot(-100; 100): ');
- try
- Readln (DotY);
- except
- Writeln('That not a number!');
- IsCorrect := False;
- end;
- if (IsCorrect and ((DotY > MAX_COORD) or (DotY < MIN_COORD))) then
- begin
- Writeln('Please, enter a coordinate between -100 and 100.');
- IsCorrect := False
- end;
- until (IsCorrect);
- Inc(X1);
- Inc(X2);
- Inc(Y1);
- Inc(Y2);
- if ((DotX > X1) and (DotX < X2)) or ((DotX < X1) and (DotX > X2)) then
- begin
- if ((DotY > Y1) and (DotY < Y2) or (DotY < Y1) and (DotY > Y2)) then
- Writeln('Belongs to rectangle!')
- else
- Writeln('Does not belong to rectangle!')
- end
- else
- Writeln('Does not belong to rectangle!');
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement