| |
|
|
p.specht
|
Window Title "Lexikographisch aufsteigende Permutation eingegebener Worte"
' (F) P. woodpecker 2011, V1.02beta in XProfan11.2a free, without Gewähr!
Declare t$,t$[],n&,k&,j&,u&,v&,e%,z&,q$
WHILE 1:CLS:e%=1:z&=0:q$=" "
print " Info: really ALLE Permutationen go here only then supplied, wenn"
print " The items To Beginn in lexikalisch aufsteigender follow indicated go! "
print "Example: 1|3|3|4|4.. or Alfons Berta Charly Emil Gustav"
print " input the items Please with space or | as Trenner:\n"
input t$:print:t$=trim$(t $):t$=translate $(t$," "," "):case instr("|",t$):q$="|"
t$=translate $(t$," ","|"):t$[]=explode(t$,"|"):n&=SizeOf(t $[])
print "--- Start ex the angegebenen Lexikal-Permutation ---"
While e%
inc z&
casenot q$="|":print " ";
WhileLoop n&
print t$[&Loop-1];:case &Loop=n&:continue
print q$;
EndWhile
print
if n&<2:e%=0:break:endif
k&=n&-2
While t$[k&]>=t $[k&+1]
Dec k&
case k&<0:break
EndWhile
if k&<0:e%=0:break:endif
j&=n&-1
While t$[j&]<=t $[k&]
dec j&
EndWhile
t$=t $[k&]:t$[k&]=t $[j&]:t$[j&]=t$
u&=k&+1:v&=n&-1
While u&<v&
t$=t $[u&]:t$[u&]=t $[v&]:t$[v&]=t$
inc u&:dec v&
EndWhile
EndWhile
print "-------------- spent Lines:",z&,"-----------------"
WAITINPUT
ENDWHILE
END
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 04/11/21 ▲ |
|
|
|