main()
{float n,s;
for (s=0,n=1;n<=50;n++)
{s=s+__________;}
printf("%f" ,s);}
c语言的题目:求和运算:1-1\/3+1\/5-1\/7+...+1\/99,
pow(-1,n-1)\/(2*n-1)pow是计算-1的n-1次方的C函数。要包含math.h头文件
c语言 求1-1\/3+1\/5-1\/7+1\/9~~~知道某一项的绝对值小于1e-6 我写出...
printf("近似值=",t*4);没有传进去,printf("近似值=%f",t*4);应该是这样吧
怎样用C语言求1-1\/3+1\/5-1\/7...的和
include<stdio.h>int main(){int n,i; double s=0; scanf("%d",&n); for(i=1;i<=n;i+=2) if(i%4==1)s+=1.0\/i; else s-=1.0\/i; printf("%lf\\n",s); return 0;}
怎样用C语言求1-1\/3+1\/5-1\/7...的和
i += 2) { total += (1.0 \/ i*s); s = -s; } printf("total = %lf\\n", total);}运行结果:请输入数值的范围n:7 total = 0.723810
求1-1\/3+1\/5-1\/7+……1\/n的值。c语言怎么写
int n, j = -1; double i = 0, s = 1; printf("输入一个奇数n:"); scanf("%d", &n); for (i = 3; i <= n; i += 2) { s = s + (1 \/ i)*j; j = -j; } printf("%lf", s); } 已赞过 已踩过< 你对这个回答的评价是? 评论 收起 听不清啊 高能答主 2018-12...
c语言编程求数列的1\/1-1\/3+1\/5-1\/7+1\/9……前20项的累计和?
include <stdio.h> int main(){ int num = 1, sign = 1, term = 1;double sum = 1.00;while (num <= 20){ sign = -sign;term = term + 2;sum = sum + ( (double) sign \/ term);num++;} printf("前20项和=%0.2f", sum);} ...
C语言计算数列1 - 1\/3 + 1\/5 - 1\/7 + 1\/9 - 1\/11 + …的前n项之和...
){long n;while (scanf_s("%ld", &n) != -1){double s = 0.0;int i, a = 1;for (i = 1; i <= 2 * n - 1; i += 2){if (((i + 1) \/ 2) % 2 == 1)s += 1.0 \/ i;elses -= 1.0 \/ i;}printf("%.5f\\n", s); \/\/这里改了}return 0;} ...
c语言求解:计算数列S=1-1\/3+1\/5-1\/7+1\/9-1\/11+……的值,直到最后一项的...
C代码和运行结果如下:输出符合样例,望采纳~附源码:include <stdio.h> int main() { double s = 0;int i, sign = 1; \/\/ sign表示正负号 for (i = 1; 1.0 \/ i >= 0.0000001; i += 2) { s += sign * 1.0 \/ i;sign = -sign;} printf("%lf\\n", s);return 0;} ...
C语言编程:用while循环求1+1\/3+1\/5+1\/7+1\/9+...+1\/(2n-1)的值。n由...
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, exit...\\n");return 0;...
c语言问题(算1-1\/3+1\/5-1\/7+1\/9)
sum=sum+1\/(2*i-1)*k;改为:sum=sum+1.0\/(2*i-1)*k;