链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1183
题目:
题意:给出一个平行四边形的相邻两条边,求另一个点的坐标
分析:用数学中的向量和好解决,坑在需要判断相邻两边里三个点哪个是公共点,我的方法比较笨拙。
题解:
题目:
Given are the (
x;y
) coordinates of the endpoints of two adjacent sides of a parallelogram. Find the
(
x;y
) coordinates of the fourth point.
题意:给出一个平行四边形的相邻两条边,求另一个点的坐标
分析:用数学中的向量和好解决,坑在需要判断相邻两边里三个点哪个是公共点,我的方法比较笨拙。
题解:
#include<iostream>
double s[8];
void change()
{
double temp;
if(s[0]==s[4]&&s[1]==s[5])
{
temp=s[0],s[0]=s[2],s[2]=temp;
temp=s[1],s[1]=s[3],s[3]=temp;
}
else if(s[0]==s[6]&&s[1]==s[7])
{
temp=s[0],s[0]=s[2],s[2]=temp;
temp=s[1],s[1]=s[3],s[3]=temp;
temp=s[4],s[4]=s[6],s[6]=temp;
temp=s[5],s[5]=s[7],s[7]=temp;
}
else if(s[2]==s[6]&&s[3]==s[7])
{
temp=s[4],s[4]=s[6],s[6]=temp;
temp=s[5],s[5]=s[7],s[7]=temp;
}
}
int main()
{
//freopen("in.txt","r",stdin);
while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",s,s+1,s+2,s+3,s+4,s+5,s+6,s+7))
{
change();
double ansx,ansy;
ansx=s[6]+(s[0]-s[2]);
ansy=s[7]+(s[1]-s[3]);
printf("%.3lf %.3lf\n",ansx,ansy);
}
return 0;
}