自己记录自己吧 关注:1贴子:235
  • 5回复贴,共1

2L计算20!.将结果显示在文本框text1中。
3L求 1! + 2! + ……+10!
4L已知sum=12×22×32×…×102,编写程序,求S值,并将结果打印在Picture1上。
5L编写函数fun,函数的功能是:求1到m之间的偶数之积。
6Lsum函数的功能为求阶乘和, 要求在窗体上显示
7L计算数组中各元素的乘积。
8L计算x!和x*y



IP属地:陕西1楼2012-06-05 10:20回复

    计算20!.将结果显示在文本框text1中。
    Private Sub Command1_Click()
    Dim i As Integer, t As Single
    t = 1
    For i = 2 To 10
    t = t * i
    Next
    Text1.Text = t
    End Sub


    IP属地:陕西2楼2012-06-05 10:21
    回复
      2025-08-16 19:25:49
      广告
      不感兴趣
      开通SVIP免广告

      编写函数fun,函数的功能是:求1到m之间的偶数之积。
      Function fun(m As Integer) As Integer
      Dim k As Integer
      k =1
      For i = 2 To m Step 2
      k= k * i
      Next
      fun= k
      End Function
      Private Sub Command1_Click()
      Print fun(11)
      End Sub
      


      IP属地:陕西5楼2012-06-05 10:23
      回复

        sum 函数的功能为求阶乘和, 要求在窗体上显示
        nsum = 1
        nsum = 3
        nsum = 6
        nsum = 10
        nsum = 15
        Private
        Sub Command1_Click()
        Dim n As Integer, isum As Integer
        For n = 1 To 5
        nsum = tim(n)
        Form1.Print "nsum="; nsum
        Next n
        End Sub
        Private Function tim(n As Integer)
        Static j As Integer
        j = j + n
        tim = j
        End Function


        IP属地:陕西6楼2012-06-05 10:24
        回复

          计算数组中各元素的乘积。
          Function mul(m() As Integer)
          Dim t As Double, i%
          t = 1
          For i = LBound(m) To UBound(m)
          t = t * m(i)
          Next i
          mul = t
          End Function
          Private Sub Command1_Click()
          Dim a(1 To 8) As Integer, b%(2 To 12)
          For i = 1 To 8
          a(i) = i
          Next i
          For i = 2 To 12
          b(i) = i
          Next i
          x = mul(a())
          y = mul(b())
          Print "x="; x, "y="; y
          End Sub


          IP属地:陕西7楼2012-06-05 10:27
          回复

            计算x!和x*y
            Private Sub Command1_Click()
            Dim x As Integer, y As Integer
            x = 3
            y = 5
            Call f(x, y) 'f x, y
            End Sub
            Private Sub f(m As Integer, n As Integer)
            Dim t, i As Integer
            t = 1
            For i = 1 To m
            t = t * i
            Next i
            q = m * n
            Print t, q
            End Sub


            IP属地:陕西8楼2012-06-05 10:28
            回复