41、编写函数fun,函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。
1 1 1
S=1 + ── + ─── + ... + ──────
1+2 1+2+3 1+2+3+...+n
例如:若n的值为11时,函数的值为:1.833333
注意: 部分源程序在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
#include double fun(int n)
{ }
main()
{ int n; double s;
void
printf("\nPlease enter N:"); scanf("%d", &n);
s = fun(n);
printf("the result is: %f\n", s);
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|