UVA10112 Myacm Triangles

思路:枚举一下就好啦


#include<stdio.h>
#include<math.h>
struct list
{
   int x,y;
}map[20];
double s_get(struct list a, struct list b,struct list c)
{
   return fabs(0.5*((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x)));
}//得出三个点构成的三角形的面积
int cha(struct list a,struct list b,struct list c,struct list d)
{
   return s_get(a,b,c) == s_get(a,b,d)+s_get(a,c,d)+s_get(b,c,d);
}//判断点是不是在三角形的内部。
int main()
{
   int n;
   char c[100];
   int x,y,z;
   while(scanf("%d%*c",&n)&&n)
   {
      double m=-1.0;
      int i,j,k;
      for(i=0;i<n;i++)
      {
          scanf("%c%d%d%*c",&c[i],&map[i].x,&map[i].y);
      }
      for(i=0;i<n;i++)//一次枚举
      {
         for(j=i+1;j<n;j++)
         {
            for(k=j+1;k<n;k++)
            {
               int flag=1,p;
               for(p=0;p<n;p++)
               {
                  if(p==k||p==i||p==j)continue;
                  if(cha(map[i],map[j],map[k],map[p]))
                  {
                     flag=0;
                     break;
                  }
               }
               if(flag&&m<s_get(map[i],map[j],map[k]))
               {
                  m=s_get(map[i],map[j],map[k]);
                  x=i;
                  y=j;
                  z=k;
               }
            }
         }
      }
      printf("%c%c%c\n",65+x,65+y,65+z);
   }
   return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值