/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
permutation algorithm
Fra : hhs


Dato : 20-12-01 16:47

I guess there is no function(library) about permutation algorithm in visual
basic

Please let me know the permutation algorithm

I want to get next permutation sequence from Given sequence
12345 ->12354 ->12435->..



 
 
Tomas Christiansen (22-12-2001)
Kommentar
Fra : Tomas Christiansen


Dato : 22-12-01 00:15

hhs wrote:
> I guess there is no function(library) about permutation algorithm in
visual
> basic

Not as far as I know.

> Please let me know the permutation algorithm

The algorihm? I can give som code - its not that complicated!

It requires at ListBox names List1 on the form to output the
permutations:

Sub Permute(ByVal Symbols As String, _
Optional ByVal Permutation As String = "")
Dim Position As Long
If Len(Symbols) > 0 Then
For Position = 1 To Len(Symbols)
Permute Left(Symbols, Position - 1) & _
Mid(Symbols, Position + 1), _
Permutation & Mid(Symbols, Position, 1)
Next Position
Else
List1.AddItem Permutation
End If
End Sub

You call it by: Permute "12345"

-------
Tomas


Søg
Reklame
Statistik
Spørgsmål : 177511
Tips : 31968
Nyheder : 719565
Indlæg : 6408597
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste