HDU 1086 You can Solve a Geometry Problem too(水题)
来源:互联网 发布:linux apt安装 编辑:程序博客网 时间:2024/05/21 19:44
题意:给你几条线段统计有几个交点
#include<iostream>using namespace std;struct point{ double x,y;};struct line{ point st,en;}l[101];double cross(point a,point b,point c)///叉积{ return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);}int main(){ int n,i,j,k; while(cin>>n&&n) { for(i=0;i<n;i++) { cin>>l[i].st.x>>l[i].st.y>>l[i].en.x>>l[i].en.y; } k=0; for(i=0;i<n;i++) for(j=i+1;j<n;j++) { if(cross(l[i].st,l[i].en,l[j].st)*cross(l[i].st,l[i].en,l[j].en)<1e-10&&cross(l[j].st,l[j].en,l[i].st)*cross(l[j].st,l[j].en,l[i].en)<1e-10)///相互跨立即相交 k++; } cout<<k<<endl; }}
0 0
- 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/hdoj 1086 You can Solve a Geometry Problem too
- hdu-1086You 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 1086You 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
- 关于mybatis的insertintoselect命令未结束问题
- [C++]高精度 bign (重载运算符版本)
- 收集到的Android权限都很实用的(permission)大全
- 图像的“膨胀”与“腐蚀”
- 【规律】HDU3067小t的游戏
- HDU 1086 You can Solve a Geometry Problem too(水题)
- QT源代码阅读
- Android studio导入Eclipse项目,和一些错误的解决
- java web 开发中 eclipse 或myeclipse无法解析导入 javax.servlet 的解决方法
- 机器学习——支持向量机SVM在R中的实现
- 蓝桥杯 奇怪的分式
- 关于下载google play上的apk
- iOS UIImageView 的使用
- Zigbee之旅(四):几个重要的CC2430基础实验——定时器中断