c++ 使用for语句实现sum=1+1/(1+2)+1/(1+2+3)+...+1/(1+2+3+...+10)

如题所述

#include <stdio.h>

int main()

{int i,t=0;

double s=0;

for(i=1;i<11;i++)

{t+=i;

s+=1.0/t;

}

printf("%lf\n",s);

return 0;

}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答