| ||||||||||
| 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 | |||||||||
大牛们帮我看看吧。。。我实在不知道自己的代码哪里出了问题。。。WA得青衫湿了都。。#include<stdio.h>
#include<math.h>
struct point {
int x;
int y;
};
int det(int x1,int y1,int x2,int y2){
return x1*y2-x2*y1;
}
int cross(struct point a,struct point b,struct point c){
return det(b.x-a.x,b.y-a.y,c.x-a.x,c.y-a.y);
}
main(){
struct point s[2],t[2];
double a1,b1,c1,a2,b2,c2;
int c;
printf("INTERSECTING LINES OUTPUT\n");
scanf("%d",&c);
while(c--){
scanf("%d%d%d%d%d%d%d%d",&s[0].x,&s[0].y,&s[1].x,&s[1].y,&t[0].x,&t[0].y,&t[1].x,&t[1].y);
a1=s[0].y-s[1].y;
a2=t[0].y-t[1].y;
b1=s[1].x-s[0].x;
b2=t[1].x-t[0].x;
c1=s[0].x*s[1].y-s[1].x*s[0].y;
c1=t[0].x*t[1].y-t[1].x*t[0].y;
if(cross(s[0],s[1],t[0])==0 && cross(s[0],s[1],t[1])==0){
printf("LINE\n");
}
else{
if((s[0].x-s[1].x)*(t[0].y-t[1].y)-(s[0].y-s[1].y)*(t[0].x-t[1].x)==0)
printf("NONE\n");
else
printf("POINT %.2lf %.2lf\n",(b1*c2-b2*c1)/(b2*a1-b1*a2),(a1*c2-a2*c1)/(b1*a2-a1*b2));
}
}
printf("END OF OUTPUT\n");
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator