| |
|
|
p.specht
|
Título de la ventana "NONREKURSIVES STRING-QUICKSORT"
Declarar NumMax&,A$[],Stack1&[],Stack2&[],StackPtr&,HeadPtr&
Declarar TailPtr&,Pivot$,a&,b&,t$,q&,r&,p&,s&,i&,ms1&,sec!,m&: J0:
Cls:Imprimir "Wieviele Random 8-Signo-Cuerdas? ";:Entrada NumMax&
Selección aleatoria:i&=0:Mientras que i&<NumMax&
A$[i&]=chr$(65+int(@rnd(26)))+chr$(65+int(@rnd(26)))+chr$(65+int(@rnd(26)))+\
chr$(65+int(@rnd(26)))+chr$(65+int(@rnd(26)))+chr$(65+int(@rnd(26)))+\
chr$(65+int(@rnd(26)))+chr$(65+int(@rnd(26)))
'imprimir a$[i&],
Inc i&:EndWhile :ms1&=&GetTickCount:StackPtr&=0:HeadPtr&=0
TailPtr&=NumMax&-1:imprimir :imprimir "Starte Nonrekursives Quicksort...";: J2:
Mientras que HeadPtr&<TailPtr& : Pivot$=A$[(HeadPtr&+TailPtr&)/2]
a&=HeadPtr& : b&=TailPtr&: J1:
Mientras que A$[a&]<Pivot$:inc a&:EndWhile
Mientras que A$[b&]>Pivot$:dec b&:EndWhile
If a&<b& : t$=A$[a&] : A$[a&]=A$[b&] : A$[b&]=t$: inc a&: dec b&: Goto "J1"
EndIf :If a&=b&:q&=b&-1:r&=a&+1: Más :q&=b&:r&=a&:EndIf
inc StackPtr&:p&=HeadPtr&:s&=TailPtr&
If (q&-p&)<(s&-r&):Stack1&[StackPtr&]=r&:Stack2&[StackPtr&]=s&
HeadPtr&=p&:TailPtr&=q&:Más :Stack1&[StackPtr&]=p&
Stack2&[StackPtr&]=q&:HeadPtr&=r&:TailPtr&=s&:EndIf :EndWhile
If StackPtr&>0:HeadPtr&=Stack1&[StackPtr&]:TailPtr&=Stack2&[StackPtr&]
dec StackPtr&:Goto "J2":EndIf :sec!=(&GetTickCount-ms1&)/1000:imprimir
Imprimir "Kontrollausgabe (cada " + str$(int(NumMax&/30+1))+". Element):"
WhileLoop 0,NumMax&-1,int(1+NumMax&/30):Imprimir A$[&Loop],:EndWhile :imprimir
imprimir:imprimir "Sort-Dauer para "+str$(NumMax&)+" $-Variables: "+\
str$(sec!)+" Sek.":imprimir:imprimir "Taste...":WaitInput :Goto "J0"
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 14.04.2021 ▲ |
|
|
|