hdu1086 You can Solve a Geometry Problem too
2013-07-11 18:37
274 查看
#include <stdio.h> //(abXac)(abXad)<0 && (cdXca)(cdXcb)<0 struct segment { double x1,y1,x2,y2; }seg[102]; int Judge(int i,int j) { double a,b,c,d,x,y,a1,b1; a=seg[i].x1-seg[j].x1; b=seg[i].y1-seg[j].y1; a1=seg[i].x2-seg[j].x1; b1=seg[i].y2-seg[j].y1; c=seg[j].x2-seg[j].x1; d=seg[j].y2-seg[j].y1; x=a*d-b*c; y=a1*d-b1*c; if(x*y<=0) return 1; else return 0; } int main() { int n,i,j,count; while(scanf("%d",&n)&&n) { count=0; for (i=1;i<=n;i++) { scanf("%lf %lf %lf %lf",&seg[i].x1,&seg[i].y1,&seg[i].x2,&seg[i].y2); } for (i=1;i<n;i++) { for(j=i+1;j<=n;j++) if(Judge(i,j)&&Judge(j,i)) count++; } printf("%d\n",count); } return 0; }
相关文章推荐
- HDU1086:You can Solve a Geometry Problem too(线段相交模板)
- You can Solve a Geometry Problem too (hdu1086)几何,判断两线段相交
- hdu1086 You can Solve a Geometry Problem too (判断两线段是否相交)
- HDU1086 You can Solve a Geometry Problem too
- HDU1086_You can Solve a Geometry Problem too(几何/叉积判断点线关系)
- HDU1086 You can Solve a Geometry Problem too
- You can Solve a Geometry Problem too (hdu1086)几何,判断两线段相交
- HDU1086 You can Solve a Geometry Problem too
- hdu1086 You can Solve a Geometry Problem too
- hdu1086 You can Solve a Geometry Problem too【排斥实验+跨立实验】
- HDU1086 You can Solve a Geometry Problem too(数学几何)
- hdu1086 You can Solve a Geometry Problem too
- ACM-计算几何之You can Solve a Geometry Problem too——hdu1086
- HDU1086_You can Solve a Geometry Problem too_判断两线段相交
- hdu1086 You can Solve a Geometry Problem too
- HDU-1086 You can Solve a Geometry Problem too 解题报告
- hdu You can Solve a Geometry Problem too(判断两条线段相交)
- HDU 1086 You can Solve a Geometry Problem too
- HDU 1086 You can Solve a Geometry Problem too 线段相交
- HDU 1086 You can Solve a Geometry Problem too(判断线段是否相交,非规范相交)