two c-ordinate of square given how to find other two using c++
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
#define INF 1e18
//typedef long long LL;
//typedef __int64 LL;
int main()
{
int x1,x2,y1,y2;
int x3,y3,x4,y4;
while(~scanf("%d%d%d%d",&x1,&y1,&x2,&y2))
{
int t;
if(x1 == x2 )
{
t = y1-y2;
if(t < 0)
t = -t;
x3 = x1+t,x4 = x2+t;
y3 = y1, y4 = y2;
printf("%d %d %d %d\n",x3,y3,x4,y4);
continue;
}
if(y1 == y2)
{
t = x1-x2;
if(t < 0)
t = -t;
y3 = y1+t,y4 = y2+t;
x3 = x1, x4 = x2;
printf("%d %d %d %d\n",x3,y3,x4,y4);
continue;
}
//if ((y2-y1) == (x2-x1))//slope 1
if ((y2-y1) == (x2-x1) || (y2-y1) == - (x2-x1))//slope of 1 or -1
{
x3 = x1, y3 = y2;
x4 = x2, y4 = y1;
printf("%d %d %d %d\n",x3,y3,x4,y4);
continue;
}
printf("-1\n");
}
return 0;
}