A vector of points on the plane is normalized if all the following three conditions hold:
The vector contains at least two different elements.
The sum of all the -coordinates of the points in the vector equals the sum of all the -coordinates of the points in the vector.
The barycenter of the points in the vector does not belong to the vector.
Recall that the barycenter of a set of points is the point of the plane which has the average value of the -coordinates of the points as -coordinate, and the average value of the -coordinates of the points as -coordinate.
Make a program that reads vectors of points on the plane and determines
whether they are normalized or not.
Your program must use the following definition:
struct Point
double x,y;
;
and it must also define, implement and use the following function:
bool barycenter (const vectorPoint& v, Point& b);
which, given a vector of points , it computes in the barycenter of the points in and returns a boolean indicating whether is to be found in or not.
The input consists in several lines with sequences. Each sequence describes a vector of points by means of a natural number , which is followed by pairs of real numbers , , , , describing the coordinates of the points in the vector.
For each vector of points, the output indicates the barycenter of its points and whether the vector is a normalized one or not. In case the vector is not normalized, the output indicates which of the three required properties of the definition is the first one not holding.
You are asked to follow the output format of the examples.
Real numbers must be written using 2 digits in their fractional part. Use:
cout.setf(ios::fixed);
cout.precision(2);
Input
3 0 0 0 0 0 0 4 1 0 1 1 1 0 1 0 3 0 1 0 -1 0 0 3 0 1 1 0 1 1 4 0 0 1 0 0 1 0 0 3 0 0 1 1 0 0
Output
barycenter: (0.00,0.00) property 1 does not hold barycenter: (1.00,0.25) property 2 does not hold barycenter: (0.00,0.00) property 3 does not hold barycenter: (0.67,0.67) normalized vector barycenter: (0.25,0.25) normalized vector barycenter: (0.33,0.33) normalized vector