您的位置:首页 > 其它

POJ-1005

2015-07-11 00:52 344 查看
#include<iostream>
#include<cmath>
//#include<algorithm>
using namespace std;

#define PI 3.1415926

/*
return: years
*/
int recursionFunc(float rCurrent, float xYMin){
float r;

if(rCurrent==0){
r=sqrt(100.0/PI);
}else{
r=sqrt(100.0/PI+pow(rCurrent,2));
}

if(r>xYMin){
return 1;
}else{
return 1+recursionFunc(r, xYMin);
}
}

int main(int argc, char *argv[]){
int n;
float x,y;
float r;
cin>>n;
for(int i=0;i<n;i++){
cin>>x>>y;
r=sqrt(pow(x,2)+pow(y,2));

cout<<"Property "<<i+1<<": This property will begin eroding in year "<<recursionFunc(0,r)<<"."<<endl;
}

cout<<"END OF OUTPUT."<<endl;

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: