Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal.
Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points.
Input
The input consists of three lines, each containing a pair of integer coordinates x i and y i ( - 1000 ≤ x i, y i ≤ 1000). It’s guaranteed that these three points do not lie on the same line and no two of them coincide.
Output
First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices.
Then print k lines, each containing a pair of integer — possible coordinates of the fourth point.
题意 : 给出平行四边形的三个顶点 求出另一个顶点 及其种可能数
思路: 画出图 以两个点为标记 记录一个向量 另一个点加减这个向量 再换成另一个还没有记录过的位置
代码:
#include<bits/stdc++.h>
using namespace std;
struct Point{
int x, y;
};
int main(){
Point P[3];
Point p[3];
for(int i =0; i < 3; i++)
cin >> P[i].x >>P[i].y;
int dx = P[0].x - P[1].x;
int dy = P[0].y - P[1].y;
p[0].x = P[2].x + dx;
p[0].y = P[2].y + dy;
p[1].x = P[2].x - dx;
p[1].y = P[2].y- dy;
dx = P[1].x - P[2].x;
dy = P[1].y - P[2].y;
p[2].x = P[0].x + dx;
p[2].y = P[0].y + dy;
cout << 3 <<endl;
for(int i = 0; i <3; i++)
cout << p[i].x << ' ' <<p[i].y <<endl;
}