2. 班长的任务
program ex_2;
var
t, n, i, j : integer;
a : array[1 .. 2, 1 .. 60] of integer;
noswap : boolean;
begin
readln(n);
for i := 1 to n do
read(a[1, i]);
for i := 1 to n do
read(a[2, i]);
for i := 1 to n do
begin
noswap := true;
for j := 1 to n-i do
if (a[1, j] > a[1, j+1]) or ((a[1, j] = a[1, j+1]) and (a[2, j] > a[2, j+1])) then
begin
t := a[1, j];
a[1, j] := a[1, j+1];
a[1, j+1] := t;
t := a[2, j];
a[2, j] := a[2, j+1];
a[2, j+1] := t;
noswap := false;
end;
if (noswap) then break;
end;
for i := 1 to n do
write(a[1, i], ' ');
writeln;
for i := 1 to n do
write(a[2, i], ' ');
writeln;
readln;
readln;
end.
var
t, n, i, j : integer;
a : array[1 .. 2, 1 .. 60] of integer;
noswap : boolean;
begin
readln(n);
for i := 1 to n do
read(a[1, i]);
for i := 1 to n do
read(a[2, i]);
for i := 1 to n do
begin
noswap := true;
for j := 1 to n-i do
if (a[1, j] > a[1, j+1]) or ((a[1, j] = a[1, j+1]) and (a[2, j] > a[2, j+1])) then
begin
t := a[1, j];
a[1, j] := a[1, j+1];
a[1, j+1] := t;
t := a[2, j];
a[2, j] := a[2, j+1];
a[2, j+1] := t;
noswap := false;
end;
if (noswap) then break;
end;
for i := 1 to n do
write(a[1, i], ' ');
writeln;
for i := 1 to n do
write(a[2, i], ' ');
writeln;
readln;
readln;
end.


浙公网安备 33010602011771号