首页 旅游资讯 线路攻略 景点大全 国内游 境外游 美食特产

VB(VBA,VBS)编程,求组合数Cmn (m为下角标,n为上角标)组合数的可能的情况...

发布网友 发布时间:2024-10-24 11:15

我来回答

1个回答

热心网友 时间:2024-11-17 16:47

x=InputBox("请输入一个数字:",,"5")
x1=x
y=InputBox("请输入一个比"&x&"小的数字:",,"3")
s=Result(x1,y)

For i=1 To y
Execute "z"&i&"=i"
Next

for i=1 to s
d=""
For j=1 To y
d = d&eval("z"&j)&" "
Next
Execute "x"&i&"=d"
Execute "z"&y&"=z"&y&"+1"
gm()
next

for i=1 to s
st=st&vbcr&eval("x"&i)&"-- "&i
next
msgbox "C("&x&","&y&")"&vbcrst&"有 "&s&" 种排列方法:"&vbcrst&st

Function Result(a,b)
sa=1:sb=1
if a<>"" and b<>"" then
for i = 1 to b
sa = sa*a
sb = sb*i
a = a-1
next
Result = sa/sb
end if
End Function

Function gm()
For q=y To 2 Step -1
If eval("z"&q)=q+x-y+1 Then
Execute "z"&q-1&"=z"&q-1&"+1"
For p=q To y
Execute "z"&p&"=z"&p-1&"+1"
next
End If
Next
End Function

热心网友 时间:2024-11-17 16:51

x=InputBox("请输入一个数字:",,"5")
x1=x
y=InputBox("请输入一个比"&x&"小的数字:",,"3")
s=Result(x1,y)

For i=1 To y
Execute "z"&i&"=i"
Next

for i=1 to s
d=""
For j=1 To y
d = d&eval("z"&j)&" "
Next
Execute "x"&i&"=d"
Execute "z"&y&"=z"&y&"+1"
gm()
next

for i=1 to s
st=st&vbcr&eval("x"&i)&"-- "&i
next
msgbox "C("&x&","&y&")"&vbcrst&"有 "&s&" 种排列方法:"&vbcrst&st

Function Result(a,b)
sa=1:sb=1
if a<>"" and b<>"" then
for i = 1 to b
sa = sa*a
sb = sb*i
a = a-1
next
Result = sa/sb
end if
End Function

Function gm()
For q=y To 2 Step -1
If eval("z"&q)=q+x-y+1 Then
Execute "z"&q-1&"=z"&q-1&"+1"
For p=q To y
Execute "z"&p&"=z"&p-1&"+1"
next
End If
Next
End Function

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com