View Code of Problem 15

#include<stdio.h>
#include<math.h>
double x[100],y[100];
int main()
{
	int n;
	int time=0;
	while(scanf("%d",&n)!=EOF,n!=0)
	{
		int j;
		int m;
		double s=0;
		for(j=0;j<=n;j++)
		{
		scanf("%d",&m);
		if(m==0) break;
        int i;
		for(i=1;i<=m;i++)
			scanf("%lf%lf",&x[i],&y[i]);
        for(i=2;i<=m;i++)
		{
			s=s+fabs(x[i-1]*y[i]-x[i]*y[i-1]);
		}
		s+=fabs(x[m]*y[1]-x[1]*y[m]);
		}
		printf("Case #%d: ",++time);
		printf("%.4f\n",s/2);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 15