11智能在线
新记
用C语言编程:求1-1/2+1/3-1/4+1/5-1/6+…+1/99-1/100+…的值…
如题所述
举报该文章
相关建议 2017-08-21
#include<stdio.h>
int main()
{int i=1,n;
float s=0;
scanf("%d",&n);
while(i<=n)
{if(i%2)s+=1.0/i;
else s-=1.0/i;
i++;
}
printf("%f\n",s);
return 0;
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/7444sqs44qqspm248p.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
用C语言编程:求1-1/2+1/3-1/4+1/5-1/6+...
用C语言编程:求1-1/2+1/3-1/4+1/5-1/6+...
c语言 编写一个程序 1-1/2+1/3-1/4+1/5……...
c语言计算 1-1/2+1/3-1/4+1/5-1/6......
用C语言编写程序求1-1/2+1/3-1/4+1/5-1/6...
用C语言编程:求1-1/2+1/3-1/4+1/5-1/6+...
C语言编写函数求:1-1/2+1/3-1/4+1/5-1/6...
1-1/2+1/3+1/4-1/5+1/6+1/7+1/8-...