#include #include #define DEBUG 0 // implemented without arrays for the benefit of 1020 students main() { int cases,i; int x1,y1,x2,y2,x3,y3,x4,y4, x5,y5; int xx,yy,xxx,yyy; int c,a,b; double dist1,dist2,dist3,dist4,dist5; scanf("%d\n",&cases); for(i=1; i<=cases;i++) { scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",&xx,&yy,&xxx,&yyy,&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&x5,&y5); // compute a,b,c if(xx==xxx) {a = 1; b=0;c=-xx;} else{ a = yyy-yy;b= xx-xxx;c = xx*(yy-yyy) + yy*(xxx-xx); } //compute distances dist1 = (a*x1+b*y1+c)/sqrt(a*a+b*b); dist2 = (a*x2+b*y2+c)/sqrt(a*a+b*b); dist3 = (a*x3+b*y3+c)/sqrt(a*a+b*b); dist4 = (a*x4+b*y4+c)/sqrt(a*a+b*b); dist5 = (a*x5+b*y5+c)/sqrt(a*a+b*b); if(DEBUG) printf("d = %lf %lf %lf %lf %lf\n", dist1,dist2,dist3,dist4,dist5); if (((dist1<0)&&(dist2<0)&&(dist3<0)&&(dist4<0)&&(dist5<0))||((dist1>0)&&(dist2>0)&&(dist3>0)&&(dist4>0)&&(dist5>0))) printf("Case %d: The points are all on the same side.\n",i); else printf("Case %d: The points are not all on the same side.\n",i); } }