由坐标 (0,0) 开始,以半圆为形状每年侵蚀50 平方 miles ,问你从 (0,0) 开始到 (x,y) 结束需要多长时间。
不难。
#include <cmath>
#include <iostream>
using namespace std;
typedef struct a_XY {
float X;
float Y;
} a_XY;
int main() {
float pi = 3.14159;
int i = 0;
float *area;
int n;
cin >> n;
a_XY *p_xy = new a_XY[n];
area = new float[n];
for (i = 0; i < n; i++) {
cin >> p_xy[i].X;
cin >> p_xy[i].Y;
}
for (i = 0; i < n; i++) {
area[i] = pi * (p_xy[i].X * p_xy[i].X + p_xy[i].Y * p_xy[i].Y) / 2;
if (area[i] > 0) {
cout << "Property " << i + 1;
cout << ":" << " This property will begin eroding in year ";
cout << (int) (area[i] / 50) + 1 << "." << endl;
} else continue;
}
cout << "END OF OUTPUT." << endl;
return 0;
}