|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
writing function for permutationCan anyone help to write permutation function for following formula.. nPr = n!/(n-r)! where n is length of given string and r is lengh of subset.. for example..if given string is "abcd" and r = 2 then out put shuld be ab ac ad ba bc bd..and so on... and if r = 3 then output shuld be abc abd acb acd and so on... Any help would be highly appreciated.. thnx dave On Thu, 2 Feb 2006 16:10:12 +1100, "dave" <noj***@nojunk.com> wrote: I think this is what you want :->Hi There >Can anyone help to write permutation function for following formula.. >nPr = n!/(n-r)! >where n is length of given string and r is lengh of subset.. >for example..if given string is "abcd" and r = 2 then out put shuld be >ab >ac >ad >ba >bc >bd..and so on... Option Explicit: DefObj A-Z ' Combinations : J French 7th Aug 03 Private Sub Command1_Click() Dim Dest$ Call LS_Combine(2, "", "ABCDE", Dest$) Me.AutoRedraw = True Me.Print Dest$ 'Open "c:\t\test.txt" For Output As #1 'Print #1, Dest$ 'Close #1 End Sub Private Sub LS_Combine(SampleSize%, RootIn$, FullSetIn$, Dest$) Dim L9%, Root$, NewFullSetIn$ ' --- At bottom - take result and exit If SampleSize = 0 Then Dest$ = Dest$ + RootIn$ + vbCrLf Exit Sub End If ' --- For each possible Start Letter For L9 = 1 To Len(FullSetIn$) ' --- Build Root Root$ = RootIn$ + Mid$(FullSetIn$, L9, 1) NewFullSetIn$ = Left$(FullSetIn$, L9 - 1) _ + Mid$(FullSetIn$, L9 + 1) ' --- Handle Residue Call LS_Combine(SampleSize% - 1, _ Root$, _ NewFullSetIn$, _ Dest$) Next End Sub
USB-Memorystick - serial number
Hpw to make a VB6 form appears and gets focus every 15 seconds Do we have such a container control? Writing to .TXT file question www Link in VB 6... Need help regarding the program... Please help me.. It's very Urgent Book for web dev with VS2005? missing reference Connection MSComm application hangs - comEventRxOver |
|||||||||||||||||||||||