Слайд 2Алгоритм
for i := 1 to m - 1 do
for j :=
1 to m - i do
if A[ j ] > A[ j + 1] then begin
k := A[ j ];
A[ j ] := A[ j + 1];
A[ j + 1] := k;
end;
Слайд 3k
i=1
1
9
2
4
8
3
5
4
10
6
j :=1 to 9
j :=
1
if A[1] > A[ 2] then begin
k
:= A[ 1 ];
A[ 1 ] := A[ 2 ];
A[ 2 ] := k;
Слайд 4k
i=1
1
9
2
4
8
3
5
4
10
6
j :=1 to 9
j :=
2
if A[ 2 ] > A[ 3 ]
then begin
k := A[ 2 ];
A[ 2 ] := A[ 3 ];
A[ 3 ] := k;
Слайд 5k
i=1
1
2
9
4
8
3
5
4
10
6
j :=1 to 9
j :=
3
if A[ 3 ] > A[ 4 ]
then begin
k := A[ 3 ];
A[ 3 ] := A[ 4 ];
A[ 4 ] := k;
Слайд 6k
i=1
1
2
4
9
8
3
5
4
10
6
j :=1 to 9
j :=
4
if A[ 4 ] > A[ 5 ]
then begin
k := A[ 4 ];
A[ 4 ] := A[ 5 ];
A[ 5 ] := k;
Слайд 7k
i=1
1
2
4
8
9
3
5
4
10
6
j :=1 to 9
j :=
5
if A[ 5 ] > A[ 6 ]
then begin
k := A[ 5 ];
A[ 5 ] := A[ 6 ];
A[ 6 ] := k;
Слайд 8k
i=1
1
2
4
8
3
9
5
4
10
6
j :=1 to 9
j :=
6
if A[ 6 ] > A[ 7 ]
then begin
k := A[ 6 ];
A[ 6 ] := A[ 7 ];
A[ 7 ] := k;
Слайд 9k
i=1
1
2
4
8
3
5
9
4
10
6
j :=1 to 9
j :=
7
if A[ 7 ] > A[ 8 ]
then begin
k := A[ 7 ];
A[ 7 ] := A[ 8 ];
A[ 8 ] := k;
Слайд 10k
i=1
1
2
4
8
3
5
4
9
10
6
j :=1 to 9
j :=
8
if A[ 8 ] > A[ 9 ]
then begin
k := A[ 8 ];
A[ 8 ] := A[ 9 ];
A[ 9 ] := k;
Слайд 11k
i=1
1
2
4
8
3
5
4
6
10
9
j :=1 to 9
j :=
9
if A[ 9 ] > A[ 10 ]
then begin
k := A[ 9 ];
A[ 9 ] := A[ 10 ];
A[ 10 ] := k;
Слайд 12k
i=2
1
2
4
8
3
5
4
6
10
9
j :=1 to 8
j :=
1
if A[ 1 ] > A[ 2 ]
then begin
k := A[ 1 ];
A[ 1 ] := A[ 2 ];
A[ 2 ] := k;
Слайд 13k
i=2
1
2
4
8
3
5
4
6
10
9
j :=1 to 8
j :=
2
if A[ 2 ] > A[ 3 ]
then begin
k := A[ 2 ];
A[ 2 ] := A[ 3 ];
A[ 3 ] := k;
Слайд 14k
i=2
1
2
4
8
3
5
4
6
10
9
j :=1 to 8
j :=
3
if A[ 3 ] > A[ 4 ]
then begin
k := A[ 3 ];
A[ 3 ] := A[ 4 ];
A[ 4 ] := k;
Слайд 15k
i=2
1
2
4
8
3
5
4
6
10
9
j :=1 to 8
j :=
4
if A[ 4 ] > A[ 5 ]
then begin
k := A[ 4 ];
A[ 4 ] := A[ 5 ];
A[ 5 ] := k;
Слайд 16k
i=2
1
2
4
3
8
5
4
6
10
9
j :=1 to 8
j :=
5
if A[ 5 ] > A[ 6 ]
then begin
k := A[ 5 ];
A[ 5 ] := A[ 6 ];
A[ 6 ] := k;
Слайд 17k
i=2
1
2
4
3
5
8
4
6
10
9
j :=1 to 8
j :=
6
if A[ 6 ] > A[ 7 ]
then begin
k := A[ 6 ];
A[ 6 ] := A[ 7 ];
A[ 7 ] := k;
Слайд 18k
i=2
1
2
4
3
5
4
8
6
10
9
j :=1 to 8
j :=
7
if A[ 7 ] > A[ 8 ]
then begin
k := A[ 7 ];
A[ 7 ] := A[ 8 ];
A[ 8 ] := k;
Слайд 19k
i=2
1
2
4
3
5
4
6
8
10
9
j :=1 to 8
j :=
8
if A[ 8 ] > A[ 9 ]
then begin
k := A[ 8 ];
A[ 8 ] := A[ 9 ];
A[ 9 ] := k;
Слайд 20k
i=3
1
2
4
3
5
4
6
8
10
9
j :=1 to 7
j :=
1
if A[ 1 ] > A[ 2 ]
then begin
k := A[ 1 ];
A[ 1 ] := A[ 2 ];
A[ 2 ] := k;
Слайд 21k
i=3
1
2
4
3
5
4
6
8
10
9
j :=1 to 7
j :=
2
if A[ 2 ] > A[ 3 ]
then begin
k := A[ 2 ];
A[ 2 ] := A[ 3 ];
A[ 3 ] := k;
Слайд 22k
i=3
1
2
4
3
5
4
6
8
10
9
j :=1 to 7
j :=
3
if A[ 3 ] > A[ 4 ]
then begin
k := A[ 3 ];
A[ 3 ] := A[ 4 ];
A[ 4 ] := k;
Слайд 23k
i=3
1
2
3
4
5
4
6
8
10
9
j :=1 to 7
j :=
4
if A[ 4 ] > A[ 5 ]
then begin
k := A[ 4 ];
A[ 4 ] := A[ 5 ];
A[ 5 ] := k;
Слайд 24k
i=3
1
2
3
4
5
4
6
8
10
9
j :=1 to 7
j :=
5
if A[ 5 ] > A[ 6 ]
then begin
k := A[ 5 ];
A[ 5 ] := A[ 6 ];
A[ 6 ] := k;
Слайд 25k
i=3
1
2
3
4
4
5
6
8
10
9
j :=1 to 7
j :=
6
if A[ 6 ] > A[ 7 ]
then begin
k := A[ 6 ];
A[ 6 ] := A[ 7 ];
A[ 7 ] := k;
Слайд 26k
i=3
1
2
3
4
4
5
6
8
10
9
j :=1 to 7
j :=
7
if A[ 7 ] > A[ 8 ]
then begin
k := A[ 7 ];
A[ 7 ] := A[ 8 ];
A[ 8 ] := k;
Слайд 27k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
1
if A[ 1 ] > A[ 2 ]
then begin
k := A[ 1 ];
A[ 1 ] := A[ 2 ];
A[ 2 ] := k;
Слайд 28k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
2
if A[ 2 ] > A[ 3 ]
then begin
k := A[ 2 ];
A[ 2 ] := A[ 3 ];
A[ 3 ] := k;
Слайд 29k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
3
if A[ 3 ] > A[ 4 ]
then begin
k := A[ 3 ];
A[ 3 ] := A[ 4 ];
A[ 4 ] := k;
Слайд 30k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
4
if A[ 4 ] > A[ 5 ]
then begin
k := A[ 4 ];
A[ 4 ] := A[ 5 ];
A[ 5 ] := k;
Слайд 31k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
5
if A[ 5 ] > A[ 6 ]
then begin
k := A[ 5 ];
A[ 5 ] := A[ 6 ];
A[ 6 ] := k;
Слайд 32k
i=4
1
2
3
4
4
5
6
8
10
9
j :=1 to 6
j :=
6
if A[ 6 ] > A[ 7 ]
then begin
k := A[ 6 ];
A[ 6 ] := A[ 7 ];
A[ 7 ] := k;
Слайд 33k
i=5
1
2
3
4
4
5
6
8
10
9
j :=1 to 5
j :=
1
if A[ 1 ] > A[ 2 ]
then begin
k := A[ 1 ];
A[ 1 ] := A[ 2 ];
A[ 2 ] := k;
Слайд 34k
i=5
1
2
3
4
4
5
6
8
10
9
j :=1 to 5
j :=
2
if A[ 2 ] > A[ 3 ]
then begin
k := A[ 2 ];
A[ 2 ] := A[ 3 ];
A[ 3 ] := k;