| ||||||||||
| 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 <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,i,j,k,l,flag;
double M;
struct node
{
int x;
int y;
} a[55];
double cross(node T,node p,node q)
{
return (p.x-T.x)*(q.y-T.y)-(p.y-T.y)*(q.x-T.x);
}
int temp[5];
int main()
{
char c;
while(scanf("%d",&n)&&n)
{
getchar();
for(int i=0; i<n; i++)
{
scanf("%c",&c);
scanf("%d%d",&a[i].x,&a[i].y);
getchar();
}
M=0.0;
memset(temp,0,sizeof(temp));
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
for(k=j+1; k<n; k++)
{
flag=1;
for(l=0; l<n; l++)
{
if(l!=i&&l!=j&&l!=k
&&cross(a[i],a[l],a[j])<=0
&&cross(a[j],a[l],a[k])<=0
&&cross(a[k],a[l],a[i])<=0)
{
flag=0;
break;
}
}
if(flag)
{
double s=0.5*fabs((a[i].x-a[k].x)*(a[j].y-a[k].y)-(a[i].y-a[k].y)*(a[j].x-a[k].x));
if(s>M)
{
M=s;
temp[1]=i;
temp[2]=j;
temp[3]=k;
}
}
}
}
}
printf("%c%c%c\n",temp[1]+'A',temp[2]+'A',temp[3]+'A');
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator