PI设置为3.1415927 WA了一次!
#include <iostream>
#include <cmath>
using namespace std;
const double PI = 3.1415926;
int main()
{
int t;
cin >> t;
for(int i = 1; i <= t; i++)
{
double x, y;
cin >> x >> y;
double d = x * x + y * y ;
double s = 0.5 * PI * d;
int year = ceil(s / 50.0);
printf("Property %d: This property will begin eroding in year %d.\n", i, year);
if(i == t)
printf("END OF OUTPUT.\n");
}
return 0;
}

本文展示了一个使用C++编写的简单程序,该程序通过输入坐标数据计算特定位置开始受到侵蚀的具体年份。通过给定的公式计算半径并利用π(圆周率)进行面积估算,最终确定土地侵蚀开始的年份。
371

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



