Câu 1:
const fi='dulieu.dat'
fo='thaythe.out'
var f1,f2:text;
a:array[1..100]of string;
n,d,i,vt:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n]);
end;
for i:=1 to n do
begin
d:=length(a[i]);
vt:=pos('anh',a[i]);
while vt<>0 do
begin
delete(a[i],vt,3);
insert('em',a[i],vt);
vt:=pos('anh',a[i]);
end;
end;
for i:=1 to n do
writeln(f2,a[i]);
close(f1);
close(f2);
end.
Câu 2:
uses crt;
const fi='mang.inp'
fo='sapxep.out'
var f1,f2:text;
a:array[1..100]of integer;
i,n,tam,j:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
assign(f2,fo); rewrite(f2);
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(f1,a[i]:4);
for i:=1 to n-1 do
for j:=i+1 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
write(f2,a[i]:4);
close(f1);
close(f2);
end.