编程题 (1.docVIP

  • 66
  • 0
  • 约 9页
  • 2017-06-11 发布于河南
  • 举报
编程题 (1

1/*编写函数fun,它的功能是:求n以内(不包括n)同时能被5与11整除的所有自然数之和的平方根s,并作为函数值返回。 例如,n为1000时,函数值应为s=96.979379。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序:*/ #include math.h #include stdio.h #includestdlib.h double fun(int n) { /***************Begin************/ double s=0.0; int i; for (i=0;in;i++) if(i%5==0i%11==0) s=s+i; s=sqrt(s); return s; /*************** End ************/ } void main() { FILE *wf; printf(s=%f\n, fun(1000)); /******************************/ wf=fopen(debug\\out6.dat,w); fprintf(wf,%lf,fun(1000)); fclose(wf); /*****************************/ } 2/*编写函数fu

文档评论(0)

1亿VIP精品文档

相关文档