主题:[讨论]【求救】选择排序改冒泡!!!【急用,在线等!】
下面程序是选择排序:
const n=10;
var a:array[1..10] of integer;
i,j:integer;
temp:integer;
begin
randomize;
for i:= 1 to n do a[i]=random(100);
for i:= 1 to n-1 do
for j:=i+1 to mdo
[color=FF0000]if a[i]>a[j] then (只能改这一行!) [/color]
begin
temp:=a[i];a[i]:=a[j]; a[j]:=temp;
end;
writeln('result');
for i = 1 to n do writeln (a[i]:3);
end.
只能改红色一行,怎么改成冒泡??
const n=10;
var a:array[1..10] of integer;
i,j:integer;
temp:integer;
begin
randomize;
for i:= 1 to n do a[i]=random(100);
for i:= 1 to n-1 do
for j:=i+1 to mdo
[color=FF0000]if a[i]>a[j] then (只能改这一行!) [/color]
begin
temp:=a[i];a[i]:=a[j]; a[j]:=temp;
end;
writeln('result');
for i = 1 to n do writeln (a[i]:3);
end.
只能改红色一行,怎么改成冒泡??