# uses windos CRT Const 7000 Type arr array of integer Var arr integer h

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128``` ```uses windos,CRT; Const n =7000; Type arr=array[1..n] of integer; Var a:arr;i:integer;h1,h2,m1,m2,s1,s2,hund1,hund2,diff : Word; procedure StraightSelection(a:arr); var i,j,k,x:integer; begin for i:=1 to n-1 do begin k:=i; x:=a[i]; for j:=i+1 to n do if a[j]a[j] then begin x:=a[j-1]; a[j-1]:=a[j]; a[j]:=x; end; end; procedure ShakerSort(a:arr); var i,j,k,left,right,x:integer; begin left:=2; right:=4; k:=n; repeat for j:=right downto left do if a[j-1]>a[j] then begin x:=a[j-1]; a[j-1]:=a[j]; a[j]:=x; k:=j; end; left:=k+1; for i:=left to right do if a[j-1]>a[j] then begin x:=a[j-1]; a[j-1]:=a[j]; a[j]:=x; k:=j; end; right:=k-1; until left>right; end; procedure QuickSort(a:arr); procedure sort(left,right:integer); var i,j,x,w:integer; begin i:=left; j:=right; x:=a[(left + right) div 2]; repeat while a[i] < x do i:=i+1; while a[j]j; if lefti then sort(i,right); end; begin sort(1,n); end; procedure printA(a:arr); var i:integer; begin for i:=1 to n do writeln(a[i]); end; Begin clrscr; for i:=1 to n do a[i]:=random(30000); gettime(h1, m1, s1, hund1); StraightSelection(a); gettime(h2, m2, s2, hund2); if hund1>hund2 then writeln('Straight Selection Sort ',s2-s1,':',hund2+hund1) else writeln('Straight Selection Sort ',s2-s1,':',hund2-hund1); gettime(h1, m1, s1, hund1); QuickSort(a); gettime(h2, m2, s2, hund2); if hund1>hund2 then writeln('Quick Sort ',s2-s1,':',hund2+hund1) else writeln('Quick Sort ',s2-s1,':',hund2-hund1); gettime(h1, m1, s1, hund1); BubbleSort(a); gettime(h2, m2, s2, hund2); if hund1>hund2 then writeln('Bubble Sort ',s2-s1,':',hund2+hund1) else writeln('Bubble Sort ',s2-s1,':',hund2-hund1); gettime(h1, m1, s1, hund1); ShakerSort(a); gettime(h2, m2, s2, hund2); if hund1>hund2 then writeln('Shaker Sort ',s2-s1,':',hund2+hund1) else writeln('Shaker Sort ',s2-s1,':',hund2-hund1); readkey; End. ```