题目大意:
Fred Mapper考虑在Louisiana买一块地建房子。在考察的过程中,他了解到Louisiana正在以每年50平方米的速度为萎缩。他需要知道他的房子几年后消失
输入一个坐标,输出资产几年后消失
解题思路:
计算坐标到原点的半圆的面积,然后相除即可
代码如下:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int n,i,count;
double x,y;
double c,sum;
double year;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
count=sum=0;
scanf("%lf%lf",&x,&y);
c=x*x+y*y;
c=c*3.1415926/2;
while(sum<c)
{
count++;
sum+=50*1.0;
}
printf("Property %d: This property will begin eroding in year %d.\n",i,count);
}
printf("END OF OUTPUT.");
return 0;
}
本文介绍了一个简单的方法来计算位于Louisiana的房产因土地萎缩而消失的时间。通过输入房产坐标,利用半圆面积公式估算该房产占地面积,并据此计算出若干年后房产完全被侵蚀所需的年数。
1147

被折叠的 条评论
为什么被折叠?



