2011-11-27
好吧,小朋友的数学题。
#include <iostream>
#include <math.h>
using namespace std;
const double PI = atan(1.)*4.;
int getYear(double, double);
int main ()
{
int iInput;
double dX;
double dY;
cin >> iInput;
int iCount = iInput;
while (iInput --)
{
cin >> dX >> dY;
cout << "Property " << iCount - iInput << ": This property will begin eroding in year " << getYear(dX, dY) << "." <<endl;
}
cout << "END OF OUTPUT." << endl;
}
int getYear(double dX, double dY)
{
double dRadius2 = pow(dX, 2) + pow(dY, 2);
double dArea = PI * dRadius2 / 2;
int r = dArea / 50 + 1;
return r;
}