dim intS[5] as integer
dim i,n as integer  'n为年数n=20 for i = 1 to n next

解决方案 »

  1.   

    不好意思,误操作。接着写
    dim intS[5] as integer
    dim i,n,x as integer  'n为年数
    dim intTotal as integer '牛的总数
    n=20
    intS[1]=1
    for i = 1 to 5
      intS[i]=0 
    next
    for i = 1 to n
      intS[0]=intS[0]+intS[5]
      intS[5]=intS[4]
      intS[4]=intS[3]
      intS[3]=intS[2]
      intS[2]=intS[1]
      intS[1]=intS[0]
    next
    intTotal=0
    for i=0 to 5
      intTotal=intTotal+intS[i]
    next
      

  2.   

    定义一动态数组
    第一次长度为一,其值为5(大于4即可)
    for i=1 to 20
    begin
    1:依次判断数组的值,若大于4,则数组长度加一,新值为0(牛的年龄)
    2:数组值全部加一
    end
    数组长度=牛数量
      

  3.   

    Dim n(1 To 4) As Integer
        Dim t As Integer
        Dim i As Integer
        n(4) = 1
        For i = 1 To 20
            t = n(4)
            n(4) = n(4) + n(3)
            n(3) = n(2)
            n(2) = n(1)
            n(1) = t
        Next
        Debug.Print n(1) + n(2) + n(3) + n(4)
        '907
      

  4.   

    Private Function HowManyCow(oldcows As Integer, years As Integer) As Long
    Dim oldCow As Integer
    Dim oneCow As Integer
    Dim twoCow As Integer
    Dim threeCow As Integer
    Dim fourCow As Integer
    Dim n As Integer
    Dim temp As Integer
    Dim i As Integer
    n = years
    oldCow = oldcows
    For i = 1 To n
    temp = oldCow
    oldCow = oldCow + fourCow
    fourCow = threeCow
    threeCow = twoCow
    twoCow = oneCow
    oneCow = temp
    Print "µÚ" & i & "Ä꣺" & oldCow + oneCow + twoCow + threeCow + fourCow
    Next
    HowManyCow = oldCow + oneCow + twoCow + threeCow + fourCow
    End Function
      

  5.   

    n = 50
    s = 1
    For i = 1 To n - 4
        s = s + i
        If i - 4 > 0 Then
            For j = 1 To i - 4
                s = s + j
            Next
        End If
    Next
    s = s + n
    MsgBox s + n
      

  6.   

    Dim i As Integer, n As Integer, s As Integer, j As Integer
    n = 50
    s = 1
    For i = 1 To n - 4
        s = s + i
        If i - 4 > 0 Then
            For j = 1 To i - 4
                s = s + j
            Next
        End If
    Next
    s = s + n
    MsgBox s + n
      

  7.   

    n为年数,sum为牛数,x为一头牛的生育能力,即一年生头牛
    sum=n*x
    for i=1 to ((n div 4)-1)
        sum=sum +(n-4)*xnext i
      

  8.   

    错了
    n为年数,sum为牛数,x为一头牛的生育能力,即一年生几头牛
    sum=n*x
    for i=1 to int((n-1) / 4))
        sum=sum +(n-4)*xnext i
      

  9.   

    Public count1 As Integer
    Private Sub Command1_Click()
        Dim CowOldSum As Integer  '年数
        Dim CowCount As Integer   '纪录牛总数
        CowCount = 0
        If Text1.Text >= 4 Then
            For CowOldSum = Text1.Text To 1 Step -3
                Call aa(CowOldSum)
            CowCount = count1 + CowCount
            Next CowOldSum
            If ((Text1.Text - 4) Mod 3 = 0) Then
                CowCount = CowCount + Text1.Text
            Else
                CowCount = CowCount + Text1.Text + 1
            End If
        Else
            For CowOldSum = Text1.Text To 1 Step -1
                CowCount = CowCount + 1
            Next CowOldSum
            CowCount = CowCount + 1
        End If
        MsgBox CowCount
    End Sub
    Public Sub aa(cnt As Integer)   count1 = (cnt - 3 + 1) * (cnt - 3) / 2End Sub