vb数组组合问题 Text1.text写入任意几个数字(3-9个都行)比如输入7个1234567,或者8个23456789点击按钮得 20
Text1.text写入任意几个数字(3-9个都行)比如输入7个1234567,或者8个23456789点击按钮得到每个数组组成三位数,并从小到大排列,中间是空格。比如1...
Text1.text写入任意几个数字(3-9个都行)比如输入7个1234567,或者8个23456789点击按钮得到
每个数组组成三位数,并从小到大排列,中间是空格。比如1234567 那么组成的123 124 125 126 127 134 135......
text2.text即点击按钮后得到123 124 125 126 127 134 135......(注意要从小至大的数字排列顺序) 展开
每个数组组成三位数,并从小到大排列,中间是空格。比如1234567 那么组成的123 124 125 126 127 134 135......
text2.text即点击按钮后得到123 124 125 126 127 134 135......(注意要从小至大的数字排列顺序) 展开
展开全部
Option Explicit
Private Sub Command1_Click()
Dim a(10) As Long, aMax As Long, i As Long, j As Long, k As Long
Dim s As String, t As Long
s = Text1.Text
For i = 1 To Len(s)
a(i - 1) = Mid$(s, i, 1)
aMax = i - 1
Next i
For i = 0 To aMax - 1
j = i + 1
t = a(j)
Do Until j < 1
If a(j - 1) > t Then
a(j) = a(j - 1)
j = j - 1
Else
Exit Do
End If
Loop
a(j) = t
Next i
s = ""
For i = 0 To aMax
For j = 0 To aMax
For k = 0 To aMax
If a(i) > 0 And i <> j And i <> k And j <> k Then s = s & a(i) & a(j) & a(k) & " "
Next k
Next j
Next i
Text2.Text = s
End Sub
Private Sub Command1_Click()
Dim a(10) As Long, aMax As Long, i As Long, j As Long, k As Long
Dim s As String, t As Long
s = Text1.Text
For i = 1 To Len(s)
a(i - 1) = Mid$(s, i, 1)
aMax = i - 1
Next i
For i = 0 To aMax - 1
j = i + 1
t = a(j)
Do Until j < 1
If a(j - 1) > t Then
a(j) = a(j - 1)
j = j - 1
Else
Exit Do
End If
Loop
a(j) = t
Next i
s = ""
For i = 0 To aMax
For j = 0 To aMax
For k = 0 To aMax
If a(i) > 0 And i <> j And i <> k And j <> k Then s = s & a(i) & a(j) & a(k) & " "
Next k
Next j
Next i
Text2.Text = s
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这其实是有条件的全排列,
给你个大意的程序参考
假定数长为7,数据放在数组a中,a(1)=1,a(2)=2...
for i=1 to 5
for j=i+1 to 6
for k=j+1 to 7
? a(i);a(j); a (k); " ";
next k
next j
next i
给你个大意的程序参考
假定数长为7,数据放在数组a中,a(1)=1,a(2)=2...
for i=1 to 5
for j=i+1 to 6
for k=j+1 to 7
? a(i);a(j); a (k); " ";
next k
next j
next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
zgwxm 正解..
Private Sub Command1_Click()
zf = Text1.Text
sz = Len(zf)
dzfc = ""
For i = 1 To sz - 1'是-1不是-2,不然得不到457
For j = i + 1 To sz - 1
For k = j + 1 To sz
dzfc = dzfc & " " & Trim(i) & Trim(j) & Trim(k)
Next k
Next j
Next i
Text1.Text = dzfc
End Sub
输入1234567
得到:123 124 125 126 134 135 136 145 146 156 234 235 236 245 246 256 345 346 356 456 457
Private Sub Command1_Click()
zf = Text1.Text
sz = Len(zf)
dzfc = ""
For i = 1 To sz - 1'是-1不是-2,不然得不到457
For j = i + 1 To sz - 1
For k = j + 1 To sz
dzfc = dzfc & " " & Trim(i) & Trim(j) & Trim(k)
Next k
Next j
Next i
Text1.Text = dzfc
End Sub
输入1234567
得到:123 124 125 126 134 135 136 145 146 156 234 235 236 245 246 256 345 346 356 456 457
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
zf = Text1.Text
sz = Len(zf)
dzfc = ""
For i = 1 To sz - 2
For j = i + 1 To sz - 1
For k = j + 1 To sz
dzfc = dzfc & " " & Trim(i) & Trim(j) & Trim(k)
Next k
Next j
Next i
Text1.Text = dzfc
End Sub
zf = Text1.Text
sz = Len(zf)
dzfc = ""
For i = 1 To sz - 2
For j = i + 1 To sz - 1
For k = j + 1 To sz
dzfc = dzfc & " " & Trim(i) & Trim(j) & Trim(k)
Next k
Next j
Next i
Text1.Text = dzfc
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询