图片中各项的分母不是阶乘 而是平方。
应该是你题目打错了。
按照图片中填写代码如下
double r=0;用C++编程s=1+1\/2!+1\/3!+1\/4!+……+1\/n 求恰好使s大于x的值 (急呀)
直接上代码如下,因为代码用到了阶乘,注意不要溢出。include <iostream> long greatherThan(double x){ double s = 0.0f;long result = 1;long temp = 1;while(s < x){ temp = temp * result;s += (1.0 \/ temp);result++;} return result - 1;} int main(){ std::cout << ...
用C语言编程s=1+1\/2!+1\/3!+1\/4!+……+1\/n!其中n的值由键盘输入(急...
for(int i=1;i<=n;i++)s+=1.0\/a(i);printf("%f",s);}
编写程序计算s=1+1\/2!+1\/3!+1\/4!+...1\/n!
\/\/最初结果当然是“零”啦! int p; for (p=1;p<=n;p++) result=result + 1\/factorial(p);\/\/累加 return result;}double factorial(int m){ double result=1;\/\/“0”的阶乘是“1” int i; for (i=1;i<=m;i++) result=result*i; return result;}...
求助!!c++程序设计设s=1+1\/2+1\/3+...+1\/n,求与八最接近的s的值与其对...
s+=(double)(1.0\/n) ;n++ ;}while(s<8) ; \/\/退出循环的时候,s大于8,s2小于等于8 if(8-s2>s-8) \/\/算绝对值。。。小的输出 cout<<"s="<<s<<" n="<<n-1<<endl ;else cout<<"s="<<s2<<" n="<<n-2<<endl ; \/\/输出 return 0 ; \/\/return 0;} ...
编写C程序,求1+1\/1!+1\/2!+1\/3!+1\/4!+...+1\/n!
include<iostream> using namespace std;int main(){ int n;double sum = 0;int a = 1;cout << "Please input the 'n': ";cin >> n;for(int i = 1;i <= n;i++){ for(int j = 1;j <= i;j++){ a = a*j;} sum = sum + (double)1\/(double)(a);} cout << "...
...其中:n从键盘输入。 s=1+1\/2! + 1\/3! + 1\/4! + ……+ 1\/n...
include <stdio.h>void main(){int i,j,n,k=1;float s=0;scanf("%d",&n);for(i=1;i<=n;i++){for(j=1;j<=i;j++)k=k*j;s+=1.0\/k;k=1;}printf("s=%.3f",s);}
C语言编程,s=1+1\/2-1\/3+1\/4-1\/5...+1\/n,
include <stdio.h>void fun( int n ) \/\/要传参数!!{int i;double j;double s=1;for(i=2;i<=n;i++) \/\/从2开始,s初值是1了{ \/\/多条语句要加括号j=1.0\/i; \/\/有1.0参与,不用加强转了if(i%2!=0) \/\/这里应该是ij=-j;s+=j;}printf("%lf\\n",s); \/\/double用%lf...
C语言 求和1+1\/2!+1\/3!+1\/4!+……+1\/n!
第一个空:sum=0 第二个空:i++ 第三个空:1\/t
...s=1+1\/(1+2)+1\/(1+2+3)+1\/(1+2+3+4)+...+1\/(1+2+3+...+n)_百度知...
include <stdio.h> int main(){ double s=0;int n,t=0;printf("请输入n\\n");scanf("%d",&n);int i;for(i=1;i<=n;i++){ t+=i;s+=1.0\/t;} printf("结果为:%f",s);return 0;}
用c++求1+1\/2+1\/3+1\/4+1\/n的近似值,要求至少累加到1\/n不大于0.00984为止...
include <stdio.h>int main(){int n; double s=0; n=1; do {s+=1.0\/n; }while(1.0\/n++>0.00984); printf("n=%d\\ns=%.8lf\\n",--n,s); return 0;}