hdu 1086 You can Solve a Geometry Problem too 线段相交
来源:互联网 发布:报纸数据库 编辑:程序博客网 时间:2024/05/18 13:28
#include <iostream>#include <cstdio>using namespace std;struct node{ double xs, ys; double xe, ye;}p[231];double Ijs(int i, double x, double y){ return (p[i].xs-x) * (p[i].ye-y) - (p[i].ys-y) * (p[i].xe-x);}bool Iseg(int i, int j){ if(min(p[i].xs, p[i].xe) <= max(p[j].xs, p[j].xe) && min(p[i].ys, p[i].ye) <= max(p[j].ys, p[j].ye) && min(p[j].xs, p[j].xe) <= max(p[i].xs, p[i].xe) && min(p[j].ys, p[j].ye) <= max(p[i].ys, p[i].ye) && Ijs(i, p[j].xs, p[j].ys) * Ijs(i, p[j].xe, p[j].ye) <= 0 && Ijs(j, p[i].xs, p[i].ys) * Ijs(j, p[i].xe, p[i].ye) <= 0) return true; return false;}int main(){ int n; while(scanf("%d", &n) != EOF && n) { for(int i = 0; i < n; i++) scanf("%lf%lf%lf%lf", &p[i].xs, &p[i].ys, &p[i].xe, &p[i].ye); int sum = 0; for(int i = 0; i < n-1; i++) for(int j = i+1; j < n; j++) if(Iseg(i, j)) sum++; cout << sum << endl; }}
- 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 线段相交
- 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(简单的线段相交)
- 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(几何(线段相交))
- 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(线段相交判定)
- 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 判断任意两线段是否相交
- 【线段相交】(吉大模板):hdu 1086 You can Solve a Geometry Problem too
- hdu 1086 You can Solve a Geometry Problem too(线段相交+枚举)
- HDU ACM 1086 You can Solve a Geometry Problem too->判断两线段是否相交
- 匈牙利命名法——命名规范(知道这些再看Windows程序就轻松多了)
- 网站关键词排名11位的五个原因
- poj 1979 搜索
- 约瑟夫环
- php获取正确的当前时间
- hdu 1086 You can Solve a Geometry Problem too 线段相交
- 非天然的链接的分析
- Easy Binary Compatible Interfaces Across Compilers in C++
- STL概述
- WPF学习之启动窗体设置
- ORACLE 触发器实现主键自动填充
- POJ 3259 Wormholes
- 黑马程序员—java—IO流
- 实现JavaBean和json之间的相互转换