在比赛的时候想了许久,终究还是没弄出来,刚看到一个博客里展示了一个图,顿时就想着可以试试把他推出来了,结果,这不,出来了,哈哈哈哈
给我机会推出来的那张图
There is a square in the xy-plane. The coordinates of its four vertices are (x1,y1),(x2,y2),(x3,y3) and (x4,y4)
in counter- clockwise order. (Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x1,y1) and (x2,y2), but he has forgot (x3,y3) and (x4,y4).
Given x1,x2,y1,y2, restore x3,y3,x4,y4. It can be shown that x3,y3,x4 and y4 uniquely exist and have integer values.
Constraints
·|x1|,|y1|,|x2|,|y2|≤100
·(x1,y1) ≠ (x2,y2)
·All values in input are integers.
Input is given from Standard Input in the following format:
x1 y1 x2 y2
Print x3,y3,x4 and y4 as integers, in this order.
0 0 0 1
-1 1 -1 0
#include
using namespace std;
int main()
{
int x1,y1,x2,y2,x3,y3,x4,y4;
cin>>x1>>y1>>x2>>y2;
x3=x2-(y2-y1);
y3=y2-(x1-x2);
x4=x1-(y2-y1);
y4=y1-(x1-x2);
printf("%d %d %d %d",x3,y3,x4,y4);
return 0;
}
推出来后,哇!代码这么短小精悍啊!!!