【数学几何】 已知正方形相邻两点的坐标,求另外两点的坐标

UPC Contest2219 L题 Ruined Square

在比赛的时候想了许久,终究还是没弄出来,刚看到一个博客里展示了一个图,顿时就想着可以试试把他推出来了,结果,这不,出来了,哈哈哈哈
给我机会推出来的那张图

题目描述:
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
题解:啥也不说了,全在图里,看大图

纯手工制作!!!嘿嘿嘿

AC代码:

#include<iostream>
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;
}

推出来后,哇!代码这么短小精悍啊!!!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值