有4個(gè)圓塔,圓心分別為(2,2),(-2,2),(-2,-2),(2,-2),圓半徑為1。這4個(gè)高度為10米,塔以外無建筑物。今輸入任一點(diǎn)的坐標(biāo),求該點(diǎn)的建筑高度(塔外的高度為0)。
熱心網(wǎng)友
這個(gè)是我編寫的,調(diào)試證明是正確的:#include #include void main(){double a[4][2],r,x,y,h;int i,flag;a[0][0]=2;a[0][1]=2;a[1][0]=-2;a[1][1]=2;a[2][0]=-2;a[2][1]=-2;a[3][0]=2;a[3][1]=-2;r=1;printf("Please input the x-coordinate of your point:");scanf("%lf",&x);printf("Please input the y-coordinate of your point:");scanf("%lf",&y);flag=0;for(i=0;i<4;i++){if((pow(x-a[i][0],2)+pow(y-a[i][1],2))<=pow(r,2)){flag=1;break;}}if(flag==0)h=0;elseh=10;printf("The Height at your point is:\t%lf\n\n\n",h);}。