pku2660.cpp

来自「这是ACM 方面的资料 是PKU的 北京大学的出来的」· C++ 代码 · 共 48 行

CPP
48
字号
#include <stdio.h>

typedef struct 
{
	double x, y, z;
} Point;

Point h, s[110];
int N_h, N_s;

int Test(Point *p)
{
	double ans;
	ans = h.x * (h.x - p->x) + h.y * (h.y - p->y) + h.z * (h.z - p->z);
	if (ans > 0)
	{
		return 0;
	}
	return 1;
}

int main()
{
	int i, j, cnt;
	while (scanf("%d %d", &N_s, &N_h) != -1 && (N_s + N_h))
	{
		for (i = 0; i < N_s; i++)
		{
			scanf("%lf %lf %lf", &s[i].x, &s[i].y, &s[i].z);
		}
		for (j = 0, cnt = 0; j < N_h; j++)
		{
			scanf("%lf %lf %lf", &h.x, &h.y, &h.z);
			for (i = 0; i < N_s; i++)
			{
				if (Test(s + i))
				{
					cnt++;
					break;
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?