#include<math.h>
void main()
{double s,t,n;
int x;
printf("please input n:");
scanf(%lf",&n);
t=1;x=1;s=1;
do{ x=x+2;
t=-t*/(n-10)/n;
s=s+t;
}while (x<=n);
printf("s=%lf",s);
}
编程计算1-1\/3!+1\/5!-1\/7!+...+(-1)^(n-1)\/(2n-1)!,其中n的值在程序运...
n 前 没有取地址符 scanf ("%d",&n);
1\/1!-1\/3!+1\/5!-1\/7!+...(-1)^(n+1)\/(2n-1)!的c语言算法
include<stdio.h> int main(){ int t,i,n,w;double s=1.0,p;scanf("%d",&n); \/\/输入 t=1;w=2;for(i=2;i<2*n;i+=2){ t*=(-1)*(i+1)*i;printf("t=%d\\n",t);s+=1.0\/t;} printf("%lf\\n",s);return 0;} ...
...输出结果保留4为小数 1-1\/3+1\/5+...+(-1)^(n-1)(1\/(2n-1...
int flag,denominator,i.double c,item;flag=1;denominator=1;c=0;item=0;\/\/flag表示第i项的符号,denominator表示第i项的分母,初始值为1,item为第i项的值,c存放总和 for(i=0;i<n;i++){ item=flag*1.0\/denominator; \/\/第i项的值 c=c+item; \/\/总和 flag=-flag; \/\/符...
C++如何求1\/1!-1\/3!+1\/5!-1\/n!+…+(-1)n+1\/(2n-1)!的和。
int factorial(int n);\/* 求n的阶乘 *\/ int main(int argc, char *argv[]){ int n=5;double sum=0;int i;for(i=1;i<n;i++)sum+=pow(-1,i+1)*1\/factorial(2*i-1);cout<<sum;return 0;} int factorial(int n)\/* 求n的阶乘 *\/ { if(n>1)return(n*factorial(n-1))...
利用循环语句求 1-1\/3+1\/5-1\/7+。。。+1\/(2n-1)(直到第100项的和...
楼上的是VB编程,楼主提的是C语言 int x,sum,sum1,sum2;sum1 = 1 for(i=0;i<=100;i++){ x = (1 \/ (4 * i - 1));y = (1 \/ (4 * (i + 1) - 3));sum1 = sum1 + x;sum2 = sum2 + y;} sum=sum1-sum2;...
编程求1+1\/3+1\/5++1\/7+...+1\/(2n-1)的值,n从键盘输入。要求用while或者d...
int main() { int i=1,n; float sum=0; scanf("%d",&n); do{ sum += 1.0\/i; i += 2; }while(i<=2*n-1); printf("Sum = %f\\n",sum); }
c语言求1+1\/3+1\/5+...+1\/(2n-1),求帮忙看看代码有什么问题,输出结果...
float fun(int n){float result;if (n==1)return 1;else return fun(n-1)+(float)1\/(2*n-1); \/\/ 强转} int main(){printf("%f",fun(5));system("pause");return 0;}
...循环求1+1\/3+1\/5+1\/7+1\/9+...+1\/(2n-1)的值。n由键盘输入,正整数...
代码文本:include "stdio.h"int main(int argc,char *argv[]){ int n,m;double s;printf("Enter n(int n>0)...\\nn=");if(scanf("%d",&n)==1 && n>0){ printf("s(%d) = ",n);s=m=0;while(n--)s+=1.0\/(++m)++;printf("%f\\n",s);} else printf("Input error,...
C语言编程 采纳 1+1\/3+1\/5+...+1\/2n-1
include <stdio.h>int main(){ double ans = 0.0; int n, i; scanf ("%d", &n); for (i = 1; i <= n; ++i){ ans += 1.0 \/ (double)(2*i-1); } printf ("%lf\\n", ans); return 0;} ...
求1+1\/3-1\/5+1\/7-1\/9+…1\/2n-1的Python语言代码怎么写 昆
n=int(input())sum=1 for i in range(2,n+1):if i%2==0:sum+=1\/(2*i-1)else:sum-=1\/(2*i-1)print(sum)