#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;
}
POJ-1005
最新推荐文章于 2019-03-10 12:59:03 发布
本文介绍了一个使用C++实现的递归函数,该函数用于计算圆形区域开始受到侵蚀所需的年数。通过输入不同坐标的圆形区域,程序能够计算出每个区域开始侵蚀的具体年份。
523

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



