问答题
编程题
编写函数fun(),它的功能是求n以内(不包括n)同时能被5与11整除的所有自然数之和的平方根s,并作为函数值返回。
例如:n为1000时,函数值应为s=96.979379。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
#include
double fun(int n)
{
}
main()
{
clrscr();
printf("s=%f\n", fun(1000));
}
【参考答案】
double fun(int n){double s=0.0;int i;for(i=0; i
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)