English
Source / code snippets

Kombinationen of k from n Elementen without Repeat: Knuth-X7-Algorithmus

 

p.specht

One from Prof. D. Knuth's 'Algorithm X-7' entwickeltes part uses now Procedures instead of GOTO as well as INC and DEC instead of arithmetische Indexberechnung, what The thing slow too with respect to speed useable power.
Window Title "Kombinationen-Generator for k from n Elementen without Wiederholung"
'(CL) CopyLeft 2015-09 by P.woodpecker, Wien; without jegliche Gewähr!
Window Style 24:Font 2
Declare j%,s%,b%[],n%,dflg%'...Globale variables
Main:
Cls rgb(170,255,220)
print "\n 0 for aufsteigende, 1 for absteigende Lexikalordnung?: ";:input dflg%
print "\n n = ";:input n%:print " k = ";:input s%
SetSize b%[],s%:WhileLoop s%:b%[&Loop]=&Loop+n%-s%-1:EndWhile :j%=1
COMBN'appeal the Generators, the then Kombinationen b%[1.sz%] on
'DoSomethingUseful' supply
print "\n OK. ";:WaitInput
Goto "Main"

PROC COMBN

    REPEAT

        DoSomethingUseful'with b&[1..sz&]
        case j%>s%:BREAK
        b%[j%]=b%[j%]-1:if b%[j%]<j%:inc j%:CONTINUE:endif
        :while j%>1:b%[j%-1]=b%[j%]-1:dec j%:endwhile

    UNTIL 0

ENDPROC

proc DoSomethingUseful'...here z.B. display the individual items:

    Whileloop s%,1,-1

        if dflg%=0

            print int(n%-1-b%[&Loop]),'increasing

        else

            print b%[&Loop],'decreasing

        endif

    EndWhile

    print "   ";
    case %pos>(60-s%):print

    if %csrlin>30:print "...":WaitInput:cls:endif

    endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/19/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.432 Views

Untitledvor 0 min.
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
Manfred Barei11/19/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie