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:Why wrong all the time?!请大侠们看看啊

Posted by biter at 2010-05-12 12:59:49 on Problem 1569
In Reply To:Why wrong all the time?!请大侠们看看啊 Posted by:ecjtuyushuangjian at 2006-05-25 16:15:25
> #include<iostream>
> using namespace std;
> int s,x[20],y[20];
> int fun(int i,int j,int k)
> {s=(y[k]-y[i])*(x[j]-x[i])-(y[j]-y[i])*(x[k]-x[i]);
>  if(s>0)return s;
>  else return -s;
> }
> int main()
> {int t,i,j,k,l;
>  int a,b,c;
>  int s0,s1,s2,s3;
>  char ch[20][20];
>  while(1)
>  {cin>>t;
>   if(t==0)break;
>   for(i=1;i<=t;i++)
>   cin>>ch[i]>>x[i]>>y[i];
>   a=b=c=0;s0=0;
>   for(i=1;i<=t-2;i++)
>   {for(j=i+1;j<=t-1;j++)
>    {for(k=j+1;k<=t;k++)
>     {s=fun(i,j,k);
>      for(l=1;l<=t;l++)
>      {if(l==i||l==j||l==k)goto pp;
>       else//判断点ch[l]是否在三角形内 
>       {s1=fun(i,j,l);s2=fun(i,k,l);s3=fun(j,k,l);
>         if(s<s1+s2+s3)
>          if(s>s0)
>          { s0=s;a=i;b=j;c=k;}
>       }    
>       pp:;
>      }          
>     }    
>    }   
>   }
>   cout<<ch[a][0]<<ch[b][0]<<ch[c][0]<<endl;
>  }
>  return 0;
> }
> /*
> Sample Input
> 
> 
> 6
> A 1 0
> B 4 0
> C 0 3
> D 1 3
> E 4 4
> F 0 6
> 4
> A 0 0
> B 1 0
> C 99 0
> D 99 99
> 0
> 
> Sample Output
> 
> 
> BEF
> BCD
> 
> 
> Source
> */

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