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

请大牛帮帮忙检查一下错在哪儿

Posted by 14310120133 at 2016-04-09 10:17:42 on Problem 1569
#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[1001];
int 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 main()
{
    char s[5];
    while(scanf("%d",&n)&&n)
    {
        for(int i=0; i<n; i++)
        {
            scanf("%s",s);
            scanf("%d%d",&a[i].x,&a[i].y);
        }
        M=-1.0;
        int x,y,z;
        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=fabs(0.5*((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;
                            x=i;
                            y=j;
                            z=k;
                        }
                    }
                }
            }
        }
        printf("%c%c%c\n",x+'A',y+'A',z+'A');
    }
    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