永发信息网

1、设计一个VBScript程序,计算N到M的累加和。 要求:N,M由用户给出;判断N必须小于M;N、M必须为数字。

答案:3  悬赏:0  手机版
解决时间 2021-04-07 04:11
  • 提问者网友:杀手的诗
  • 2021-04-07 01:08
1、设计一个VBScript程序,计算N到M的累加和。 要求:N,M由用户给出;判断N必须小于M;N、M必须为数字。
最佳答案
  • 五星知识达人网友:胯下狙击手
  • 2021-04-07 01:40
Function SumAll(m,n)
dim i,sum
for i = m to n step 1
sum = sum + i
next
SumAll = sum
end Function

Dim m1,n1
dim m2,n2

m1 = InputBox("please input a integer1", "num1")
if isnumeric(m1) then
m2 = m1
else
msgbox "please input integer"
m1 = InputBox("please input a integer1", "num1")
m2 = m1
end if

n1 = InputBox("please input a integer2", "num2")
if isnumeric(n1) then
n2 = n1
else
msgbox "please input integer"
n1 = InputBox("please input a integer2", "num2")
n2 = n1
end if

if n2>m2 then
temp = SumAll(m2,n2)
MsgBox "the num from "& m2 &" to " & n2 & " sum is: " & temp & " "
else
msgbox "num2 must bigger than num1"
end if
全部回答
  • 1楼网友:独钓一江月
  • 2021-04-07 03:45
没给递归终止条件喔,你来加吧
Sub T(ByVal i As Integer, ByVal n As Integer)
Dim m As Integer
m = 1
'If n = 1 Then
'终止条件
T = (T(i 1, n - 1) T(i - 1, n - 1)) / m (1 - m / 2) * T(i, n - 1)
End SubHI王刚0510
  • 2楼网友:摆渡翁
  • 2021-04-07 02:41
没给递归终止条件喔,你来加吧
Sub T(ByVal i As Integer, ByVal n As Integer)
Dim m As Integer
m = 1
'If n = 1 Then
'终止条件
T = (T(i 1, n - 1) T(i - 1, n - 1)) / m (1 - m / 2) * T(i, n - 1)
End SubHI王刚0510再交流请到it168,365testing
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯