C语言题库-第三章.docVIP

  • 45
  • 0
  • 约1.4万字
  • 约 21页
  • 2017-06-09 发布于浙江
  • 举报
程序设计 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************/ /*************** End ************/ } void main() { FILE *wf; printf(s=%f\n, fun(1000)); /******************************/ wf=fopen(debug\\out6.dat,w); fprintf(wf,%lf,fun(1000)); fclose(wf); /*****************************/ } 【参考代码】 double fun(int n) {double s=0.0; int i; for(i=0;in;i++) if(i%5==0i%11==0)

文档评论(0)

1亿VIP精品文档

相关文档