您的位置:首页 > 编程语言 > C语言/C++

C语言实验——计算表达式 (sdut oj)

2017-01-25 18:04 260 查看




C语言实验——计算表达式

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

计算下列表达式值: 


 




Input

输入x和n的值,其中x为非负实数,n为正整数。




Output

输出f(x,n),保留2位小数。




Example Input

3 2





Example Output

2.00



Hint


Author

参考代码

#include<stdio.h>
#include<math.h>
double f(double x,int n)
{
double y;
if(n == 1)
{
y = sqrt(n + x);
}
else
y = sqrt(n + f(x,n - 1));
return y;
}
int main()
{
double x;
int n;
double y;
scanf("%lf%d",&x,&n);
y = f(x,n);
printf("%.2lf\n",y);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OJ SDUT for c语言