c语言测试器是不是有毛病啊。。。
#include<stdio.h>
typedef struct point{
int x;
int y;
};
int cmp(const struct point *a,const struct point *b)
{
if(a->y!=b->y) return ((a->y)-(b->y));
else return ((a->x)-(b->x));
}
int cross(struct point a,struct point b,struct point c)
{
return ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x));
}
main()
{
struct point h[200];
struct point t[200];
struct point a[200];
struct point b[200];
int i,j,m,n,s,k,l;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++) scanf("%d %d",&a[i].x,&a[i].y);
for(i=0;i<m;i++) scanf("%d %d",&b[i].x,&b[i].y);
qsort(a,n,sizeof(struct point),cmp);
k=1; h[0]=a[0]; h[1]=a[1];
for(i=2;i<n;i++)
{
if(cross(h[k-1],h[k],a[i])>=0)
{
k++; h[k]=a[i];
}
else {
h[k]=a[i];
}
}
l=1; t[0]=a[0]; t[1]=a[1];
for(i=2;i<n;i++)
{
if(cross(t[l-1],t[l],a[i])<=0)
{
l++; t[l]=a[i];
}
else {
t[l]=a[i];
}
}
for(i=0;i<m;i++)
{
s=1;
for(j=0;j<k;j++)
{
if(cross(h[j],h[j+1],b[i])<0) { s=0; break;}
}
for(j=0;j<l;j++)
{
if(cross(t[j],t[j+1],b[i])>0) { s=0; break;}
}
printf("%d\n",s);
}
getch();
}