A. Pashmak and Garden【1200 / 思维】

在这里插入图片描述
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;
}

猜你喜欢

转载自blog.csdn.net/bettle_king/article/details/121186181