.


:




:

































 

 

 

 


.




.

¡ . "" . , "", , . , . , "fedacb" "d" :

- : f e d a c b;
- : d c a d e f;
- : a b c d e f.

¡ "" def". . , "" . . , . , . , . , , , .

¡ :

1. , . . , . : , , ; .

¡ 2. : , , , , , . :

¡ 2.1. l r, ;

¡ 2.2 m;

¡ 2.3. l m , l- ;

¡ 2.4. r m , r- ;

¡ 2.5. r = l , ;

¡ 2.6. l < r l r, . , - (l r) , m r l .

¡ 3. , .

¡ 4. , . , , , . .

( ) , , , .

program aSDfasd;

const max=20;

type list = array[1..max] of integer;

var f:list; b:integer;

procedure quicksort(var a: list; Lo,Hi: integer);

 

procedure sort(l,r: integer);

var

i,j,x,y: integer;

begin

i:=l; j:=r; x:=a[random(r-l+1)+l]; { x:= a[(r+l) div 2]; - }

repeat

while a[i]<x do i:=i+1; { a[i] > x - }

while x<a[j] do j:=j-1; { x > a[j] - }

if i<=j then

begin

if a[i] > a[j] then

begin

y:=a[i]; a[i]:=a[j]; a[j]:=y;

end;

i:=i+1; j:=j-1;

end;

until i>=j;

if l<j then sort(l,j);

if i<r then sort(i,r);

end; {sort}

 

begin {quicksort};

sort(Lo,Hi)

end; {quicksort}

begin

randomize;

for b:=1 to max do

f[b]:=random(100);

quicksort(f,1,max);

for b:=1 to max

do write (' ',f[b]);

end.

 

 





:


: 2015-10-21; !; : 480 |


:

:

, , .
==> ...

1610 - | 1283 -


© 2015-2024 lektsii.org - -

: 0.013 .