Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什么总编译错误呢?求指教、。。。

Posted by pengxin2012 at 2013-01-11 19:54:24 on Problem 1113
In Reply To:为什么总编译错误呢?求指教、。。。 Posted by:201141843222 at 2012-09-07 15:20:34
> #include <iostream>
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #define PI acos(-1)
> using namespace std;
> 
> struct point
> {
>     int x;
>     int y;
> } point;
> struct point f[1002];
> struct point tmp;
> int multiply(struct point p1,struct point p2,struct point p0)//坐标排序
> {
>     return((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y));
> }
> 
> int left(int i,int j,int k)
> {
>     int x1=f[j].x-f[i].x;
>     int x2=f[k].x-f[i].x;
>     int y1=f[j].y-f[i].y;
>     int y2=f[k].y-f[i].y;
>     if((x1*y2-x2*y1)>0)
>         return 1;
>     else return 0;
> }
> 
> double dis(int i,int j)//求两点间的距离
> {
>     return sqrt((f[j].x-f[i].x)*(f[j].x-f[i].x)+((f[j].y-f[i].y)*(f[j].y-f[i].y)));
> }
> int main()
> {
>     int i,j,k,n,l;
>     int temp,top;
>     int st[1002];
>     double sum;
>     while(scanf("%d%d",&n,&l)!=EOF)
>     {
>         k=0;
>         for(i=0; i<n; i++)
>         {
>             scanf("%d%d",&f[i].x,&f[i].y);
>             if(f[i].y<f[k].y||(f[i].y==f[k].y&&f[i].x<f[k].x))
>                 k=i;
>         }
>         temp=f[k].x;
>         f[k].x=f[0].x;
>         f[0].x=temp;
>         temp=f[k].y;
>         f[k].y=f[0].y;
>         f[0].y=temp;
>         for (i=1; i<n-1; i++)
>         {
>             k=i;
>             for (j=i+1; j<n; j++)
>                 if( (multiply(f[j],f[k],f[0])>0)||
>                    ((multiply(f[j],f[k],f[0])==0)&&(dis(0,j)<dis(0,k))) )
>                     k=j;//k保存极角最小的那个点,或者相同距离原点最近
>             tmp=f[i];
>             f[i]=f[k];
>             f[k]=tmp;
>         }
>         //printf("\n");
>         //for(i=0; i<n; i++)
>         // printf("%d %d\n",f[i].x,f[i].y);
>         top=0;
>         st[top++]=0;
>         st[top++]=1;
>         st[top++]=2;
> 
>         for(i=3; i<n;)
>         {
>             if(top<2)  st[top++]=i++;
>             else if(left(st[top-2],st[top-1],i))
>                 st[top++]=i++;
>             else
>                 top--;
>         }
>         //for(i=0;i<top;i++)
>         // printf("%d ",st[i]);
>         sum=2*PI*l;
>         for(i=0; i<top; i++)
>         {
>             if(i+1<top)
>                 sum+=dis(st[i],st[i+1]);
>             else
>                 sum+=dis(0,st[top-1]);
>         }
>         printf("%d\n",(int)(sum+0.5));
>     }
>     return 0;
> }
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator