1. 请编写一函数fun,它的功能是根据以下公式求∏的值.docVIP

  • 24
  • 0
  • 约2.49万字
  • 约 20页
  • 2019-03-16 发布于江苏
  • 举报

1. 请编写一函数fun,它的功能是根据以下公式求∏的值.doc

1. 请编写一个函数fun,它的功能是:根据以下公式求∏的值(要求满足精度0.0005,即 某项小于O.0005时停止迭代):程序运行后,如果输入精度O.0005,则程序输出为3.14…。 #include stdio.h #include math.h double fun ( double eps) {} main( ) { double x; printf(Input eps:) ; scanf(%lf,x); printf(\neps = %lf, PI=%lf\n, x, fun(x)); } 2.请编写一个函数fun,它的功能是:计算并输出给定整数n的所有因子(不包括l与自身)之和。规定n的值不大于1000。例如,若主函数从键盘给n输入的值为856,则输出为sum=763。 #include stdio.h int fun(int n) { } main() { int n,sum; printf(input n: ); scanf(%d,n); sum=fun(n); printf(sum=%d\n,sum); } 3.请编写函数fun,其功能是:计算并输出下列多项式值: 例如,若主函数从键盘给n输入8后,则输出为S=O.662872。 注意:n的值要求大于l但不大于100。部分源程序给出如下。 #include stdio.h

文档评论(0)

1亿VIP精品文档

相关文档