算法问题,向各位仁兄请教

bzm 2004-06-20 11:58:43
0 ~ 9 这10个数字

用怎么样的算法可以,把它们不同的排列顺序全体现出来呢? 在线等 ,这关系一个数字作业。我的算法,也许有问题,没把题做出来。

请用 vbscript 语法就好:)
再送您两个过程

sub printthis '打印出这十个数字
Response.write "<br>"
for i=0 to 9
response.write number(i)
next
Response.write "<br>"
end sub

sub formatnumber '将数字重设为0123456789
for i=0 to 9
number(i) = i
next
end sub


dim number(9) '数组

'下面的,就看您的啦

...全文
105 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
AKillGodKillBuddha 2004-06-23
  • 打赏
  • 举报
回复
up
ryuginka 2004-06-21
  • 打赏
  • 举报
回复
干嘛做这个题目,输出很多的
tangxiaosan001 2004-06-21
  • 打赏
  • 举报
回复
还是不明白,是水平低了,看不懂。
northwolves 2004-06-21
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
paixu 9
End Sub

Sub paixu(ByVal n As Integer)
n = n + 1
Dim I As Integer, J As Integer
Dim a() As Integer, b() As Integer, c() As String
ReDim a(n)
ReDim b(n)
ReDim c(n - 1)
I = 1
a(0) = 1
Do While I <= n + 1
a(I) = a(I) + 1
If a(I) <= n Then
If b(a(I)) = 0 Then
If I = n Then
For J = 0 To n - 1
c(J) = a(J + 1) - 1
Next
Debug.Print Join(c, " ") & vbCrLf
I = I - 1
b(a(I)) = 0
Else
b(a(I)) = 1
I = I + 1
a(I) = 0
End If
End If
Else
I = I - 1
If I = 0 Then Exit Do
b(a(I)) = 0
End If
Loop
Erase a
Erase b
Erase c
End Sub
victorycyz 2004-06-21
  • 打赏
  • 举报
回复

用SQL语句,一句话搞定。既简单又快速。
supergreenbean 2004-06-21
  • 打赏
  • 举报
回复
偶某次写过一个用递归的,不过速度有点慢……
等等吧,可能有什么人写过好的……
victorycyz 2004-06-21
  • 打赏
  • 举报
回复

上面贴的,不是你自己写的吧。根本没有写排序的算法。

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧