有4个圆塔,圆心分别为(2,2)、(-2,2)、(-2,-2)、(2,-2),圆半径为1,这4个塔的高度为10m,塔以外无建筑物。今输入任一点的坐标,求该点的建筑高度(塔外的高度为零)。
#include <stdio.h>
#include<math.h>
int main(){
int a,b,h=0;
printf("请输入坐标,中间用,隔开:");
scanf("%d,%d",&a,&b);
if (pow(a-2,2)+pow(b-2,2)<=1||pow(a-2,2)+pow(b+2,2)<=1
||pow(a+2,2)+pow(b-2,2)<=1||pow(a+2,2)+pow(b+2,2)<=1)
h=10;
printf("坐标为(%d,%d)处建筑高度为%d",a,b,h);
return 0;
}