| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
麻烦大牛帮忙看一下,谢谢啦!#include<stdio.h>
void judge(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)
{
double a1,a2,b1,b2,c1,c2;
a1=y2-y1,b1=x1-x2,c1=x1*(y2-y1)-y1*(x2-x1);
a2=y4-y3,b2=x3-x4,c2=x3*(y4-y3)-y3*(x4-x3);
if(a1*b2==a2*b1)
{
if(a1*c2==a2*c1&&b1*c2==b2*c1)
printf("LINE\n");
else
printf("NONE\n");
}
else
printf("POINT %.2f %.2f\n",(c1*b2-c2*b1)/(a1*b2-a2*b1),(c1*a2-c2*a1)/(a2*b1-a1*b2));
}
int main()
{
double x1,x2,x3,x4,y1,y2,y3,y4;
int m,i;
scanf("%d",&m);
puts("INTERSECTING LINES OUTPUT");
printf("\n");
for(i=0;i<m;i++)
{
scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
judge(x1,y1,x2,y2,x3,y3,x4,y4);
}
printf("END OF OUTPUT\n");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator