I Think I Need a Houseboat
重点是要求出半圆的面积,PI*(R^2)/2 ,R = sqrt(x^2+y^2);
所以半圆的面积为:PI*(x^2+y^2)/2;
时间为:PI*(x^2+y^2)/2/50
#include<iostream>
using namespace std;#define PI 3.141592654
int main()
{
int cases;
float x,y;
int result;
cin >> cases;
for(int i =1; i<=cases; i++)
{
cin >> x >> y;
float area = PI*(x*x+y*y);
result = (int)(area/100.0 + 1.0);
cout <<"Property "<<i<<": This property will begin eroding in year ";
cout <<result<<"."<<endl;
}
cout<<"END OF OUTPUT."<<endl;
return 0;
}