> 其他 >
题目:编写函数fun,函数的功能是:求从m到n的乘积并显示, '如:m为2,n为4时,显示"24" '存储连乘的乘积
题目:编写函数fun,函数的功能是:求从m到n的乘积并显示,
'如:m为2,n为4时,显示"24"
'存储连乘的乘积的变量必须为Product
'要求使用Do While...Loop语句来实现.
'-------------------------------------------------
'注意: 请在指定的事件内编写代码
' 代码只能写在两行标识之间
' 不得修改已有代码
'保存时不得修改窗体和工程文件的名称及路径,否则后果自负.
'-------------------------------------------------
Private Function fun(m As Integer, n As Integer) As Long
Dim Product As Double, t As Integer
If m > n Then t = m: m = n: n = t
'
End Function
Private Sub Form_Load()
Show
Print fun(4, 2)
NJIT_VB
End Sub
Private Sub NJIT_VB()
Dim i As Integer
Dim a(10) As String
Dim fIn As Integer
Dim fOut As Integer
fIn = FreeFile
Open App.Path & "\in.dat" For Input As #fIn
fOut = FreeFile
Open App.Path & "\out.dat" For Output As #fOut
For i = 1 To 10 Step 2
Line Input #fIn, a(i)
Line Input #fIn, a(i + 1)
Print #fOut, Trim(Str(fun(Val(a(i)), Val(a(i + 1)))))
Next
Close #fIn
Close #fOut
End Sub
人气:327 ℃ 时间:2019-11-22 14:56:34
解答
fun=1
t=m
do while t
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版