Zoj 1010不知道哪里有错

来源:百度知道 编辑:UC知道 时间:2024/06/05 03:48:23
真是无语了,做了一天了,总是WA,不知道哪里错了,问高手,是ZOJ 1010题
题目链接为:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1010
我的程序代码为:
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
#define N 1001
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<=b?a:b)
typedef struct Point{
double x;
double y;
}Point,pointt[N];
char C[1000];//辅助数组用于盛放带有空格的字符串
pointt point;//用来盛放n个坐标
/*判断点b相对于矢量oa上拐点a向哪拐*/
double multiply(Point a,Point b,Point o)
{
return ((b.x-o.x)*(a.y-o.y)-(a.x-o.x)*(b.y-o.y));
}
/*判断线段ij与线段mn是否相交*/
bool pointline(Point i,Point j,Point m,Point n)
{

if(max(i.x,j.x)>=min(m.x,n.x)&&max(i.y,j.y)>=min(m.y,n.y)&&max(m.x,n.x)>=min(i.x,j.x)

原因肯定是二中其一:
第一是精度问题
第二是逻辑错误
代码是没办法帮你看的,因为就是是自己写的都没办法排查出来。。
下面给你我的代码,附上一些比较典型的数据:
ps:我当年初学的时候前后经过两个月,重写了&^$$^#遍才过的,你加油,慢慢搞,一定可以的!

====================== 测试数据 =============================
5
0.01 0.01
0.01 1.01
0.51 0.51
1.01 1.01
1.01 0.01
4
0.01 0.01
0.01 1.01
1.01 0.01
1.01 1.01
4
0.01 0.01
1.01 0.01
2.01 1.01
2.01 0.01
5
0.01 0.01
2.01 0.01
2.01 1.01
1.01 0.01
0.01 1.01
4
0.01 0.01
1.01 -1.01
2.01 1.01
2.01 0.01
6
0.01 1.01
1.01 0.01
4.01 2.01
3.01 3.01
4.01 3.01
2.01 4.01
6
0.01 0.01
1.01 1.01
2.01 0.01
2.01 2.01
3.01 3.01
0.01 3.01
3
0.01 0.01
1.01 1.01
1.01 0.01

Figure 1: 0.75

Figure 2: Impossible

Figure 3: Impossible

Figure 4: Impossible

Figure 5: Impossible