matlab题目及其答案1.docVIP

  • 22
  • 0
  • 约3.29千字
  • 约 4页
  • 2018-03-13 发布于河南
  • 举报
matlab题目及其答案1

请补充main函数,该函数的功能是:计算两个自然数n和m(m10000)之间所有数的和(n和m从键盘输入)。 例如,当n=1,m=100时,sum=5050;当n=100,m=1000时,sum=495550。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include stdlib.h #include stdio.h #include conio.h void main() { int n,m; long sum; 【1】; system(CLS); printf(\nInput n,m\n); scanf(%d,%d,n,m); while(n=m) { 【2】; n++; } printf(sum=%【3】\n,sum); } 下列给定程序中,fun函数的功能是:根据形参m,计算下列公式的值: t=1+1/2+1/3+1/4+…+1/m 例如,若输入5,则应输出2.283333。 请改正程序中的错误,使它能计算出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include stdlib.h #include conio.h #include std

文档评论(0)

1亿VIP精品文档

相关文档