| |
|
|
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 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/19/21 ▲ |
|
|
|