0 bình luận về “Nhập dãy và sắp xếp số dương tăng, số âm giảm”
uses crt; var i,t,j,n:longint; a:array[1..1000000]of longint; begin clrscr; write(‘n=’);readln(n); for i:=1 to n do begin write(‘a[‘,i,’]=’);readln(a[i]); end; for i:=1 to n do for j:=1 to i do if a[i]<a[j] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end; for i:=1 to n do if a[i]>0 then write(a[i],’ ‘); writeln; for i:=n downto 1 do if a[i]<0 then write(a[i],’ ‘); readln end.
uses crt; var n,i,j,tam:longint;a:array[1..100]of longint; begin clrscr; readln(n); for i:=1 to n do readln(a[i]); for i:=1 to n do for j:=i to n do if(a[i]>a[j])then begin tam:=a[i]; a[i]:=a[j]; a[j]:=tam; end; for i:=1 to n do if(a[i]>0)then write(a[i],’ ‘); writeln; for i:=n downto 1 do if(a[i]<0)then write(a[i],’ ‘); readln; end.
uses crt;
var i,t,j,n:longint; a:array[1..1000000]of longint;
begin
clrscr;
write(‘n=’);readln(n);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’);readln(a[i]);
end;
for i:=1 to n do
for j:=1 to i do
if a[i]<a[j] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end;
for i:=1 to n do if a[i]>0 then write(a[i],’ ‘); writeln;
for i:=n downto 1 do if a[i]<0 then write(a[i],’ ‘);
readln
end.
uses crt;
var n,i,j,tam:longint;a:array[1..100]of longint;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
for j:=i to n do
if(a[i]>a[j])then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
if(a[i]>0)then write(a[i],’ ‘);
writeln;
for i:=n downto 1 do
if(a[i]<0)then write(a[i],’ ‘);
readln;
end.
5 sao nha:3