程序代码:
Option Explicit
Dim a(1 To 10) As Single
Dim b(1 To 5) As Single
Private Sub Command1_Click()
Dim i As Long
Dim j As String
i = 1
Do While i < 11
j = InputBox("请输入第 " & i & "个数", "输入初始数")
If IsNumeric(j) Then
a(i) = CSng(j)
i = i + 1
End If
Loop
Do
Call 计算 '有10个数后,先计算
Call 输出结果 '再显示结果
j = InputBox("请输入附加的数", "输入附加的数") '然后要求输入附加的数
If IsNumeric(j) Then '如果是输入的数据
Call 前移一位 '那么把现有的数据向前移一位
a(10) = CSng(j) '然后再读这个数,然后再根据循环到上面去重新计算,并显示结果
Else
Exit Do '如果输入的不是数据,则退出循环
End If
Loop
End Sub
Private Sub 计算()
'如果计算方法不,请按你的题目重写计算方法
Dim i As Long
' 1= 1+10
' 2=2+9
For i = 1 To 5
b(i) = a(i) + a(11 - i)
Next i
End Sub
Private Sub 前移一位()
Dim i As Long
For i = 2 To 10
a(i - 1) = a(i)
Next i
End Sub
Private Sub 输出结果()
Dim i As Long
Cls
For i = 1 To 10
Print "第 " & i & " 个数是:" & a(i) '输出10个数据
Next i
Print '空行
For i = 1 To 5
Print "第 " & i & " 计算结果是:" & b(i) '输出5个结果
Next i
End Sub