代码实现:
#include <stdio.h>
#include <math.h>
int judge(int x, int y) {//计算距离,并且判断哪个近
if (pow(x - 4, 2) + pow(y - 4, 2) < (pow(x + 4, 2) + pow(y + 4, 2))) {
return 1;
} else {
return 2;
}
}
int main() {
int n;
scanf("%d", &n);
for (register int i = 1; i <= n; i++) {
int t1, t2;//一次输入一组数
scanf("%d %d", &t1, &t2);
if (judge(t1, t2) == 1) {
printf("1 ");
} else {
printf("2 ");
}
}
return 0;
}