您的位置首页百科知识

函数double f(int n)返回一下表达式的值: 1+1/2+2/3+3/4+……+(n-1)/n

函数double f(int n)返回一下表达式的值: 1+1/2+2/3+3/4+……+(n-1)/n

C++版本#includeusing namespace std;double fun(int n){ cin>>n; double sum; sum=2.0-1.0/(n+1); cout<double fun(int n){ scanf("%d",&n); double sum; sum=2.0-1.0/(n+1); printf("%lf",sum); return sum;}int main(){ int x; printf("input"); fun(x); return 0;}