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

再求f(x,n)

时间:2017-08-09 19:16:00      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:sso   1.0   center   style   include   函数   递归   pid   输出   

再求f(x,n)


链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1167

【题目描述】

已知

技术分享

用递归函数求解。

【输入】

第一数是x的值,第二个数是n的值。

【输出】

函数值。

【输入样例】

1 2

【输出样例】

0.40
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
double h(int x,int n){
    if(n==1) return 1.0*x/(1+x);
    
    return 1.0*x/(n+h(x,n-1));
}
int main(){
    
    double x,n;
    cin>>x>>n;
    printf("%.2f",h(x,n));
    
}

 

再求f(x,n)

标签:sso   1.0   center   style   include   函数   递归   pid   输出   

原文地址:http://www.cnblogs.com/EdSheeran/p/7327032.html

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