发布网友 发布时间:2024-10-02 14:23
共0个回答
src(i + 1) = src(i + 1) + src(i) \ 10 src(i) = src(i) Mod 10 End If Next End Sub '主程序 Sub Main()Dim i As Integer Dim MDigit() As Integer Dim Sum() As Integer ReDim Sum(0), MDigit(0)Sum(0) = 0: MDigit(0) = 1 For i = 1 To 20 Multiply MD...
求1到20的阶乘的累加和的VB代码jc = 1 For i = 1 To n jc = jc * i Next jiecheng = jcEnd FunctionPrivate Function Factorial1(intN As Integer) As Integer'采用递归计算阶乘If intN = 0 ThenFactorial1 = 1ElseFactorial1 = Factorial1(intN - 1) * intNEnd IfEnd Function ...
vb编程试题,求1 2 3 5 8 13……前20项之和Private Sub Command1_Click()Cls Dim b() As Long, i As Integer, n As Integer n = 20 ReDim b(1 To n) b(1) = 1: b(2) = 1 For i = 3 To n b(i) = b(i - 1) + b(i - 2) Next For i = 1 To n Print b(i); Next End Sub ...
求助vb中 单击计算按钮出现1!+2!+3!...+20!的值 哪出错了For J = 1 To 20 这句错误,应改成For J = 1 To I ,否则每次I循环求得的S均为20!/I!而不是I!
VB求1-20的阶乘之和Dim i, j As Integer Dim sum, t As Double sum = 0 For i = 1 To 20 t = 1 For j = 1 To i t = t * j Next j sum = t + sum Next i MsgBox "1-20的阶乘之和为:" & sum, vbInformation, "确认"你要先建立一个窗体,在窗体上建个按钮,再将上述代码粘贴到按钮的过程...
用VB求数列1,2,3,5,16,231...的前20项Label1.Caption = ""Command1.Caption = "输入"Command2.Caption = "退出"Text2.Width = 5895 Text2.Height = 375 Text2.Top = 2520 Text2.Locked = True Label1.Caption = "前20项的次序为:"Label1.Width = 2775 Label1.Top = 2040 Text1.Top = 360 Text1.Width = 1215 End Sub ...
求数列1、1、2、3、5、8、13…的前20项之和 用VB,不要太复杂啊。Dim k1 As Long, k2 As Long, k As Long, s As Long, i As Integer k1 = 1 s = 1 For i = 1 To 20 Print k1;k = k1 + k2 s = s + k k2 = k1 k1 = k Next Print Print "前20项之和为" & s
S=1/2+2/3+3/5...求前20项之和, 用VB写出全过程dim i,a,b,c dim s a=1 b=2 for i=1 to 20 s=s+a/b c=a a=b b=b+c next i
vb程序设计:求1+2+3+5+8+13+……前20项和如图所示,望采纳。。。
VB中输出1!+2!+3!+4!+`..+20!dim s,m,i,j, as interger for i= 1 to 20 s=1 for j=1 to i s=s*j next m=m+s next print m 这个代码简单易懂,应该可以帮到你吧。参考资料:如果您的回答是从其他地方引用,请表明出处