完善vb程序1-1/2+1/3-1/4+.../99-1/100的值,救命的急

完善vb程序1-1/2+1/3-1/4+.../99-1/100的值,救命的急
private sub form_click()
dim i as integer, t as integer, sum as ingle
sum=___
t =____
for i =i to ___
t = t*-1
sum = sum +_____
next i
print "sum="; sum
end sub
公选课选了vb,头痛,,,谢谢各大侠!

private sub form_click()
dim i as integer, t as integer, sum as ingle
sum=__0_ 求和变量的初始值0
t =__-1__ 求和数的第一个是正数,与for循环的-1相乘=1
for i =1 to _100__ 需要求和的数有100个
t = t*-1 正负符号交替
sum = sum +__t/i___ 每个求和数的规律
next i
print "sum="; sum 输出和
end sub
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-06-08
Private Sub form_click()
Dim i As Integer, t As Integer, sum As Single
sum = 0
t = -1
For i = 1 To 100
t = t * -1
sum = sum + t / i
Next i
Print "sum="; sum
End Sub

编写一个程序求1-1\/2+1\/3-1\/4+...+1\/99-1\/100之值,用MATLAB
sum((-1).^(0:99).\/(1:100))

vb试题编程计算1-1\/2+1\/3-1\/4+...+1\/99-1\/100的四种方法是什么?
1:\\x0d\\x0aDim i As Integer\\x0d\\x0aDim s As Double\\x0d\\x0aDim s0 As Double\\x0d\\x0aFor i = 1 To 100\\x0d\\x0as0 = 1 \/ i\\x0d\\x0aIf i Mod 2 = 0 Then s0 = s0 * (-1)\\x0d\\x0as = s + s0\\x0d\\x0aNext\\x0d\\x0aPrint s\\x0d\\x0a\\x0d\\...

C语言程序 1-1\/2+1\/3-1\/4+...+1\/99-1\/100
如果是计算 1-1\/2+1\/3-1\/4+...+1\/99-1\/100 那么不需要输入n,其他不变就是了 如果是计算 1-1\/2+1\/3-1\/4+...+1\/n 才需要输入n 代码如下(不需要math.h头文件):include <stdio.h>void main(){ double sum; int i,n,m; \/\/加个变量i printf("请输入n:");...

计算1-1\/2+1\/3-1\/4+···+1\/99-1\/100的结果
1-1\/2+1\/3-1\/4+···+1\/99-1\/100 =1+1\/2+1\/3+1\/4+···+1\/99+1\/100-2(1\/2+1\/4+···+1\/100)=1+1\/2+1\/3+1\/4+···+1\/99+1\/100-(1+1\/2+···+1\/50)=1\/51+1\/52+···+1\/100 只能化成这样了,剩下来的只能硬来,你学过数学分析就知道了 ...

编写程序求1-1\/2+1\/3-1\/4……+1\/99-1\/100的值
function box(n) { if (n < 1 || n > 100) { return "error" } var result = 0; for (var i = 1; i <= n; i++) { if (i % 2 == 0) { result -= 1\/i; } else { result += 1\/i; } } return result;}console.log(box(100))

1-1\/2+1\/3-1\/4+···+1\/99-1\/100的值是多少
调和数列,没有公式。只能用Excel或编程计算。1-1\/2+1\/3-1\/4+···+1\/99-1\/100≈0.68817

编写一个程序求1-1\/2+1\/3-1\/4+…+1\/99-1\/100的值。
include <stdio.h> main(){ int i,k=1;float , sum=0;for(i=1;i<=100;i++){ sum+=k*1.0\/i;k=-k;} printf("sum=%f\\n",sum);}

求1-1\/2+1\/3-1\/4+...+1\/99-1\/100
第二次 程序执行:sign=(-1)sign sign原来得-1 现在得1\/\/现在到第三项了 为正 term 你想要的当前项\/\/第二次执行 sign=1 (1\/deno)=1\/3 也就是你式子的第三项 sum 你想要的和 \/\/第二次执行 sum=1-1\/2 现在 sum=1-1\/2+1\/3 就是这样继续循环下去 就得到最后的结果了 ...

编程“计算1-1\/2+1\/3-1\/4+...+1\/99-1\/100+...直到最后一项的绝对值小...
include "stdio.h"main(){ float sum=0,i=1,j,t=1;do {j=t\/i;i++;t=-t;sum+= j;}while (i<=10000);printf("1-1\/2+1\/3-1\/4+ ... +-1\/%.0f = %lf",i, sum);}

写出求S=1-1\/2+1\/3-1\/4+...+1\/99-1\/100的程序
\/\/写出求S=1-1\/2+1\/3-1\/4+...+1\/99-1\/100的程序 include "stdio.h"void main(){ int i,n=100;double sum=0;\/\/存储和的变量,初值为0 int sign=1;\/\/控制正负符号的变量 for(i=1;i<=100;i++){ sum=sum+(1.0\/i)*sign;sign=sign*(-1);} printf("S=%lf\\n",sum);...

相似回答
大家正在搜