You are to write a program which reads four (4) pairs of coordinates from a file and determines whether the points they designate can be connected to form a rectangle. The points will be stored in the file in order around the perimeter.
Here are two sets of test data:
This set DOES define a rectangle. Save it as rect1.dat.
-2.0 0 2.0 4.0 4.0 2.0 0 -2.0
This set does NOT define a rectangle. Save it as rect2.dat.
-2.0 1.0 2.0 4.0 4.0 2.0 0 -2.0
To receive full marks, you will need to handle a file presented to you at the end of class.
#include <math.h>To properly compile and link your program, you have to specify that you want the math library used. You do this by including the
-lmon the command line.
gcc -lm -g -o rectcheck rectcheck.c
vir:~$ rectcheck rect1.dat The points (-2.00, 0.00) (2.00, 4.00) (4.00, 2.00) (0.00, -2.00) DO define a rectangle. vir:~$ rectcheck rect2.dat The points (-2.00, 1.00) (2.00, 4.00) (4.00, 2.00) (0.00, -2.00) do NOT define a rectangle.