1 Đảo ngược 1 dãy số đã cho trong tệp Thu Oct 27, 2011 4:46 pm
kingofthedevils
Thành viên tích cực
uses wincrt;
var f1,f2:text;
n,i,tg:integer;
a:array[1..100] of integer;
begin
assign(f1,'d:\doctep.inp');
reset(f1);
assign(f2,'d:\doctep.out');
rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
writeln(f2,'day so da cho la:');
for i:=1 to n do
write(f2,a[i]:5);
writeln(f2);
for i:=1 to n div 2 do
begin
tg:=a[i];
a[i]:=a[n+1-i];
a[n+1-i]:=tg;
end;
writeln(f2,'day so da dao nguoc la:');
for i:=1 to n do
write(f2,a[i]:5);
close(f1);
close(f2);
end.
-Phan Bảo Duy-
var f1,f2:text;
n,i,tg:integer;
a:array[1..100] of integer;
begin
assign(f1,'d:\doctep.inp');
reset(f1);
assign(f2,'d:\doctep.out');
rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
writeln(f2,'day so da cho la:');
for i:=1 to n do
write(f2,a[i]:5);
writeln(f2);
for i:=1 to n div 2 do
begin
tg:=a[i];
a[i]:=a[n+1-i];
a[n+1-i]:=tg;
end;
writeln(f2,'day so da dao nguoc la:');
for i:=1 to n do
write(f2,a[i]:5);
close(f1);
close(f2);
end.
-Phan Bảo Duy-