HDU 2036

//原来忘了不可以数字开头,后来全部加上a
#include <cstdio>
#include <cstring>
float area(float a1x,float a1y,float a2x,float a2y,float a3x,float a3y)
{
    return 1.0/2*((a2x-a1x)*(a3y-a1y)-(a3x-a1x)*(a2y-a1y));
}
int main()
{
    int i,j,k,T;
    while(scanf("%d",&T),T)
    {
        int a1x,a1y,a2x,a2y,a3x,a3y;
        scanf("%d%d%d%d",&a1x,&a1y,&a2x,&a2y);
        float sum_area=0;
        for(i=3;i<=T;i++)
        {
            scanf("%d%d", &a3x, &a3y);
            sum_area+=area((float)a1x,(float)a1y,(float)a2x,(float)a2y,(float)a3x,(float)a3y);
            a2x=a3x;//一开始忘加了,贡献一个wa
            a2y=a3y;
        }
        printf("%.1f\n",sum_area);
    }
    return 0;
}

你可能感兴趣的:(HDU)