#include <iostream>
#include <cmath>
using namespace std;
int years(float x, float y)
{
float r = sqrt(x * x + y * y);
float square = 3.1415926 * r * r / 2;
float currentSquare = 0;
int year = 0;
while(square >= currentSquare)
{
++year;
currentSquare += 50;
}
return year;
}
int main()
{
int times;
int n = 1;
float x, y;
cin >> times;
while(times--)
{
cin >> x >> y;
cout << "Property " << n++ << ":This property will begin eroding in year " << years(x, y) << "."<< endl;
}
cout << "END OF OUTPUT." << endl;
return 0;
}
OJ百练1005
最新推荐文章于 2022-09-16 11:23:56 发布
本文介绍了一个使用C++编写的简单程序,该程序通过输入房产的坐标来计算其开始受到侵蚀的年份。程序首先计算房产的圆形面积,然后逐年增加侵蚀面积直到覆盖整个房产。适用于模拟土地侵蚀速度等问题。
309

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



