【简答题】
Dim a(100) As Integer
Private Sub Command1_Click()
Dim k As Integer
Open App.Path & "\in5.dat" For Input As #1
For k = 1 To 100
Input #1, a(k)
Next k
Close #1
End Sub
参考答案
Private Sub Command2_Click()
'考生应完成的程序
Dim s As Long, n As Integer
For i = 1 To 100
If isnarc(a(i)) Then
s = s + a(i)
n = n + 1
End If
Next i
Text1.Text = Fix(s / n)
End Sub
Function isnarc(p As Integer)
x = Fix(p / 100)
y = Fix((p - x * 100) / 10)
z = p - x * 100 - y * 10
If p = x ^ 3 + y ^ 3 + z ^ 3 Then
isnarc = True
Else
isnarc = False
End If
End Function
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\out5.dat" For Output As #1
Print #1, Text1.Text
Close #1
End Sub