赞
踩
分母不变,分子递增用while语句来控制循环
- #include <stdio.h>
- int main()
- {
- int i=1;
- double deno=2.0,sum=1.0,term;
- while(deno<=100)
- {
- i=-i;//使偶数位出现负数
- term=i/deno;
- sum=sum+term;
- deno++;
- }
- printf("%f\n",sum);
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。