码迷,mamicode.com
首页 > 其他好文 > 详细

POJ-1005

时间:2017-07-23 10:08:34      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:poj   div   return   class   std   ios   har   clu   this   

#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

标签:poj   div   return   class   std   ios   har   clu   this   

原文地址:http://www.cnblogs.com/jhcelue/p/7223603.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!