cuocsong6so
New member
- Xu
- 0
program bai4;
uses crt;
const fi='chanle.inp';
fo='chanle.out';
nmax=100;
type mang=array[1..nmax] of integer;
var n:integer;
a:mang;
procedure nhap;
var f:text;
i:integer;
begin
assign(f,fi);reset(f);
readln(f,n);
for i:=1 to n do read(f,a);
close(f);
end;
procedure xuat;
var g:text;
i:integer;
begin
assign(g,fo);rewrite(g);
for i:=1 to n do write(g,a,' ');
close(g);
end;
procedure sx;
procedure sort(d,c:integer);
var i,j,tg:integer;
begin
i:=d;
j:=c;
repeat
while odd(a) do inc(i);
while not odd(a[j]) do dec(j);
if i<= j then
begin
tg:=a;a:=a[j];a[j]:=tg;inc(i);dec(j);
end;
until i>j;
if i<c then sort(i,c);
if j>d then sort(d,j)
end;
begin
sort(1,n);
end;
begin
nhap;
sx;
xuat;
end.
:stupid:
uses crt;
const fi='chanle.inp';
fo='chanle.out';
nmax=100;
type mang=array[1..nmax] of integer;
var n:integer;
a:mang;
procedure nhap;
var f:text;
i:integer;
begin
assign(f,fi);reset(f);
readln(f,n);
for i:=1 to n do read(f,a);
close(f);
end;
procedure xuat;
var g:text;
i:integer;
begin
assign(g,fo);rewrite(g);
for i:=1 to n do write(g,a,' ');
close(g);
end;
procedure sx;
procedure sort(d,c:integer);
var i,j,tg:integer;
begin
i:=d;
j:=c;
repeat
while odd(a) do inc(i);
while not odd(a[j]) do dec(j);
if i<= j then
begin
tg:=a;a:=a[j];a[j]:=tg;inc(i);dec(j);
end;
until i>j;
if i<c then sort(i,c);
if j>d then sort(d,j)
end;
begin
sort(1,n);
end;
begin
nhap;
sx;
xuat;
end.
:stupid:
Sửa lần cuối bởi điều hành viên: