SDUT-1199 C语言实验——计算表达式

来源:互联网 发布:淘宝小号网站源码 编辑:程序博客网 时间:2024/06/09 14:41

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

Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic Discuss

Problem Description

计算下列表达式值: 

 

Input

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

Output

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

Example Input

3 2

Example Output

2.00

Code

#include <stdio.h>#include <math.h>double f(double x,int n){    int i;    double s=x;    for(i=1; i<=n; i++)    {        s=sqrt(i+s);    }    return s;}int main(){    double x;    int n;    scanf("%lf %d",&x,&n);    printf("%.2lf",f(x,n));    return 0;}