1.写一个函数F(N.P),利用这个函数设计一个函数Sum(n),求1+N+N2+...+NP.
2.利用递归输出N个元素的所有排列情况。
以上2题 希望大家多多帮忙 谢谢
以上2题 只要能在立即窗口中调试就行
谢谢大家~~~~~`

解决方案 »

  1.   

    其實一個最簡單的辦法進行排列,存進數據庫中間,然後 order by就出來了偶要斷網了,不試了。
      

  2.   

    Dim cn() As String
    Dim cs As Integer
    Dim cx() As Integer
    Dim a() As Integer
    Dim x() As IntegerSub pb()
    cs = InputBox("请输入元素的个数:")
    ReDim cn(cs)
    ReDim a(cs)
    ReDim x(cs)
    For I = 1 To cs
      cn(I) = InputBox("请输入第" & I & "个元素。")
    Next
    End Sub
    Sub try(I As Integer)
    Dim j As Integer
    DoEvents
    For j = 1 To cs
     If a(j) = 0 Then
      x(I) = j
      a(j) = 1
     If I < cs Then
      try (I + 1)
     Else
      For t = 1 To cs
       If t < cs Then
         Debug.Print cn(x(t)) & " ";
       Else
         Debug.Print cn(x(t))
       End If
      Next
     End If
     a(j) = 0
    End If
    Next
    End Sub
    Private Sub Form_Load()
    pb
    try (1)
    End Sub
      

  3.   

    2.http://expert.csdn.net/Expert/topic/2909/2909080.xml?temp=.2954828
      

  4.   

    对于第一题,题目有些不清不楚,如下是我的解答,不知是否合你的题意?Function f(n As Integer, p As Integer) As Long
    f = n * p
    End Function
    Function sum(n As Integer) As Long
    Dim i As Integer
    sum = 1
    For i = 1 To n
      sum = sum + f(i, p)
    Next
    End Function