标签:
#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; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/eddy_liu/article/details/46837331