snrg.net
当前位置:首页 >> VB编程s=1/(1*2)+1/(2*3)+1/(3*4)+....+1/n*(n+1) ... >>

VB编程s=1/(1*2)+1/(2*3)+1/(3*4)+....+1/n*(n+1) ...

看看这个行吗?Private Sub Command1_Click()Dim s, n As Doublen = InputBox("请你输入数值:", "提示")For n = 1 To ns = s + 1 / (n * (n + 1))Next nMsgBox sEnd Sub

Private Sub Command1_Click() n = InputBox("请输入n:") For i = 1 To n t = 1 / (i * (i + 1)) s = s + t Next i Print "S=" & sEnd Sub

Private Sub Form_Click() Dim i As Integer Dim sum As Double sum = 0 N=3 For i = 1 To N sum = sum + 1 / (i * (i + 1)) Next i Print sum End Sub

Private Sub CommandButton1_Click() Dim s As Double, n As Double s = 0 For i = 1 To 10 n = 1 For j = 1 To i n = n * j Next j s = s + i * n Next i Print s //print s可以换其他输出方法End Sub

''文本框txtN中键盘输入N值,txtS作为显示结果用,CmdGo为按钮Private Sub CmdGo_Click() dim i as long,j as long,k as long, N as long,s1 as long, S as long N=txtN ' s=0 for i=1 to N k=2*i-1:s1=1 for j=1 to K s1=s1*j next S=S+s1 next TxtS=SEnd Sub

用一个循环就可以 sub test() dim i as integer dim s as single for i=1 to 100 s=s+(-1)^(i+1)*(1/i) next i msgbox s,vbokonly,"结果" end sub

Private Sub C1_Click() Dim a, s As Single For i = 1 To 10 a = 1 / (i * i) s = s + a Next

搜一下:VB编程题编写程序,求s=1*2*3+2*3*4++n*(n+1)*(n+2)

1.s=0 n=val(inputbox("")) for i=1 to n s=s+i*(i+1)nextprint s--------------------------------------------------2. for i=1 to 5 for j=1 to i print i*j; next printnext---------------------

dim s as longdim i as integer'请输入n的初始值s=0i=1do s=s+1/n^2 i=i+1loop until i>=n

相关文档
tfsf.net | sbsy.net | qmbl.net | ddgw.net | alloyfurniture.com | 网站首页 | 网站地图
All rights reserved Powered by www.snrg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com