31、给定程序MODI1.C中函数fun的功能是:根据整型形参m,计算如下公式的值。
1 1 1 1
y = 1 + ----- + ----- + ----- + …… + -----
2*2 3*3 4*4 m*m
例如,若 m 中的值为: 5,则应输出:1.463611。
请改正程序中的错误,使它能得出正确的结果。
注意: 不要改动 main 函数,不得增行或删行,也不得更改程序的结构!
#include double fun ( int m )
{ double y = 1.0 ;
int i;
/**************found**************/
for(i = 2 ; i < m ; i++)
/**************found**************/
y += 1 / (i * i) ;
return( y ) ;
}
main( )
{ int n = 5 ;
printf( "\nThe result is %lf\n", fun ( n ) ) ;
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|