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*5 *_*#include<stdio.h> #include<math.h> double k[10001],x[10001],y[10001]; const int maxk=100020; struct btreenode{ double data; double x,y; btreenode *left; btreenode *right; }; bool findbstreen(btreenode *bst,double &item,double &xn,double &yn) { while(bst!=NULL){ if(fabs(item-bst->data)<0.000000001) { if(item==maxk||fabs(yn-bst->y)<0.00000000001||fabs((yn-bst->y)/(xn-bst->x)-item)<0.000000001)return 1; else bst=bst->right; } else if(item<bst->data)bst=bst->left; else bst=bst->right; } return 0; } void insertbstreen(btreenode *&bst,const double &item,double &xn,double &yn) { btreenode *t=bst,*parent=NULL; while(t!=NULL){ parent=t; if(item<t->data)t=t->left; else t=t->right; } btreenode *p=new btreenode; p->data=item;p->x=xn;p->y=yn; p->left=p->right=NULL; if(parent==NULL)bst=p; else if(item<parent->data)parent->left=p; else parent->right=p; } int main() { int i,j,kn,dn; double x1,y1,x2,y2,kt,xt,yt; btreenode *b=NULL; while(scanf("%d",&dn),dn) { kn=0;b=NULL; for(i=0;i<dn;i++) { scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2); if(x1-x2!=0)kt=(y1-y2)/(x1-x2);else kt=maxk; if(findbstreen(b,kt,x1,y1))continue; insertbstreen(b,kt,x1,y1); kn++; } printf("%d\n",kn); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator