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 |
大牛们,帮帮忙吧,不知道怎么错了!#include<stdio.h> #include<math.h> int main() { int n,h,i,j,k; double s,u,v,cir; int x[1000],y[1000]; scanf("%d%d",&n,&h); while(1) { if(n==0) break; cir=0; for(i=0;i<n;i++) scanf("%d%d",&x[i],&y[i]); // for(i=0;i<=3;i++) // printf("%d ",y[i]); cir+=sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0])); for(j=1;j<n-1;j++) { s=(h-y[j])*1.0/x[j]; if(j%2==0) u=(y[j+1]-y[j])*1.0/(x[j+1]-x[j]); else u=(y[j+1]-y[j])*1.0/(x[j]-x[j+1]); if(j%2==0) cir+=sqrt((x[j+1]-x[j])*(x[j+1]-x[j])+(y[j+1]-y[j])*(y[j+1]-y[j])); else if(s>u) cir+=sqrt((x[j+1]-x[j])*(x[j+1]-x[j])+(y[j+1]-y[j])*(y[j+1]-y[j])); } printf("%.2lf\n",cir); scanf("%d%d",&n,&h); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator