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 |
原来double可以用<=In Reply To:为什么一直WA? Posted by:sunflowwer at 2006-08-30 23:26:02 > #include <stdio.h> > #include <math.h> > #define zero 1e-6 > > struct point{ > double x; > double y; > }m1[3],m2[3]; > int work1(int a,double b) > { > double s; > struct point *p=(point *)m1; > s=sqrt(pow((p+a)->x,2)+pow((p+a)->y,2)); > if(s<b) > return 1; > if(fabs(s-b)<zero) > return 1; > return 0; > } > int work2(int a,double b) > { > double s; > struct point *p=(point *)m2; > s=sqrt(pow((p+a)->x,2)+pow((p+a)->y,2)); > if(s<b) > return 1; > if(fabs(s-b)<zero) > return 1; > return 0; > } > int main() > { > int a,b,i,j; > while(1) > { > for(i=0;i<3;i++) > scanf("%lf%lf",&m1[i].x,&m1[i].y); > for(i=0;i<3;i++) > scanf("%lf%lf",&m2[i].x,&m2[i].y); > if(fabs(m1[0].x+100.0)<zero) > break; > for(a=0,i=0;i<3;i++){ > /* if(m1[i].x>20.0 || m1[i].x<-20.0 || m1[i].y>20.0 || m1[i].y<-20.0) > continue;*/ > for(j=3;j<21;j+=3) > if(work1(i,j*1.0)){ > a+=100-(j/3-1)*20; > break; > } > } > for(b=0,i=0;i<3;i++){ > /* if(m2[i].x>20.0 || m2[i].x<-20.0 || m2[i].y>20.0 || m2[i].y<-20.0) > continue;*/ > for(j=3;j<21;j+=3) > if(work2(i,j*1.0)){ > b+=100-(j/3-1)*20; > break; > } > } > printf("SCORE: %d to %d, ",a,b); > if(a==b) > printf("TIE.\n"); > else if(a>b) > printf("PLAYER 1 WINS.\n"); > else if(a<b) > printf("PLAYER 2 WINS.\n"); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator