jcst.net
当前位置:首页 >> C++问题:1%1/2+1/3%1/4+1/5%1/6+1/7%1/8+1/9%1/10=? >>

C++问题:1%1/2+1/3%1/4+1/5%1/6+1/7%1/8+1/9%1/10=?

private sub command1_click() dim i as integer, s as double s = 0 for i = 1 to 10 s = s + (-1) ^ (i - 1) * (1 / i) next i print 0; s end sub

#include<stdio.h> main() { float sum=0; int i,a=-1; for(i=1;i<=100;i++) { a=-1*a; sum+=a*1/i; } printf("the answer is %f",sum); }

double j=1; double e=1; for(int i=1;i<11;i++){ j=j*i e=e+1/j; }

e=11!+1

#include <stdio.h>#include <math.h> int main() { unsigned long int n = pow(10,-4); unsigned long int i = 2; long double s = 1; for (i;i<=n;i++) { if (i%2 == 0) { s -= 1/i; } else { s += 1/i; } } printf("%Lf",s); }

(1+1/2+1/3+1/4)*(1/2+1/3+1/4+1/5)-(1+1/2+1/3+1/4+1/5)*(1/2+1/3+1/4)=(1+1/2+1/3+1/4)*(1+1/2+1/3+1/4+1/5)-(1+1/2+1/3+1/4)-(1+1/2+1/3+1/4+1/5)*(1/2+1/3+1/4)=(1+1/2+1/3+1/4+1/5)*[(1+1/2+1/3+1/4)-(1/2+1/3+1/4)]-(1+1/2+1/3+1/4)==(1+1/2+1/3+1/4+1/5)-(1+1/2+1/3+1/4)=1/5

展开全部#include int a[2] = {-1, 1}; float Sum(int n, int nTimes) { if(n <= nTimes) return 1.0/n * a[n%2] + Sum(n+1, nTimes); else return 0; } int main() { int nTimes = 0; scanf("%d", &nTimes); if(nTimes > 0 && nTimes < 101) printf("%f\n", Sum(1, nTimes)); return 0; }

是不是应该是1+1/2!+1/3!+1/4!++1/10!啊?//#include "stdafx.h"//If the vc++6.0, with this line.#include "stdio.h" int main(void){ int i; double sum,tmp; for(sum=0,tmp=i=1;i<11;sum+=(tmp/=i++)); printf("sum = %f\n",sum); return 0; }

当n=>∞时 S=ln21-1/2+1/3-1/4……+1/2n =1+1/2+1/3+1/4……+1/2n-2(1/2+1/4+……+1/2n) =1/(n+1)+1/(n+2)+……1/2n =1/n(1/(1+1/n)+1/(1+2/n)+……+1/(1+n/n) =1/(1+x)[从0积到1]=ln2 或者方法二 ln(1+x)=∫1/(1+x)dx (积分区间从0到x)=∫(1-x+x^2-……)dx (无穷级数展开)=x-x^/2+x^3/3-…… 收敛区间为(-1,1) 当x=1时该级数为交错级数且满足莱布尼茨判别法条件,故收敛 两边带入x=1得原式=ln2

#include void main() { double e,sum=0; int n=1,flag=1; scanf("%lf",&e); while(1.0/n>e) { sum+=flag*1.0/n; flag=-flag; n++; } printf("%.4lf\n",sum); }

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.jcst.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com