
https://codeforces.com/problemset/problem/459/A
分类讨论:
- 同行,必有解
- 同列,必有解
- 对角,看距离相不相等。
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int x,y,xx,yy; cin>>x>>y>>xx>>yy;
if(x==xx)
{
int len=abs(y-yy);
cout<<x+len<<" "<<y<<" "<<x+len<<" "<<yy<<endl;
}else if(y==yy)
{
int len=abs(x-xx);
cout<<x<<" "<<y+len<<" "<<xx<<" "<<y+len<<endl;
}else
{
int len1=abs(x-xx),len2=abs(y-yy);
if(len1!=len2) puts("-1");
else printf("%d %d %d %d",x,yy,xx,y);
}
return 0;
}
该博客主要讨论了如何在二维平面上找到从一个点到另一个点的路径,如果同行、同列或对角线上的距离相等则存在解。程序通过判断起点和终点的相对位置来输出符合条件的路径坐标。
579

被折叠的 条评论
为什么被折叠?



