acm poj 1254求acmer检查代码....

来源:百度知道 编辑:UC知道 时间:2024/05/13 02:48:26
http://acm.pku.edu.cn/JudgeOnline/problem?id=1254
这道题挺简单,但我就是错了,怎么也想不明白代码哪里错……只求更正我的代码或指出错误,其他正解我也会找,谢谢。
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
double t,x1,x2,y1,y2,d1,d2,c1,c2,s1,s2,pi;
pi=2*asin(1);
cin>>t;
double x,y;
while(t>0)
{

;cin>>x1>>y1>>d1>>x2>>y2>>d2;
c1=cos((90-d1)/180*pi); //化成于x正轴成交 解析几何都是这么做的吧 这样好看。。。。
c2=cos((90-d2)/180*pi);
s1=sin((90-d1)/180*pi);
s2=sin((90-d2)/180*pi);//所联立的方程:(y-y1)*c1=(x-x1)*s1;(y-y2)*c2=(x-x2)*s2;
x=(c1*c2*(y1-y2)-c2*s1*x1+c1*s2*x2)/(c1*s2-c2*s1);//求出x
if(c1!=0)
y=s1*(x-x1)/c1+y1;
else
y=s2*(x-x2)/c2+y2;
cout<<setiosflags(ios::fixed)<<setprecision(4);
cout<<x<<' '<<y<

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int num;
cin >> num;
while(num--)
{
double x1,y1,degree1,k1,a;
double x2,y2,degree2,k2,b;
double PI = 2*asin(1.0);
cin >> x1 >> y1 >> degree1;
cin >> x2 >> y2 >> degree2;
k1 = tan((450 - degree1)*PI/180);
k2 = tan((450 - degree2)*PI/180);
a = (k1*x1 - k2*x2 - y1 + y2)/(k1 - k2);
b = (k1*k2*(x1 - x2) + k1*y2 - k2*y1)/(k1 - k2);
printf("%.4f %.4f\n",a,b);
}
return 0;
}