Viết chương trình nhập vào một xâu có chữ “anh” và chữ “em”. Xuất ra màn hình xâu đổi chữ “anh” thành chữ “em”, chữ “em” thành chữ “anh”.

2 câu trả lời

Bài mik làm đây bạn 

NHỚ CHO MIK CÂU TLHN NHA

Bài đây bạn

Program hotrotinhoc;

var s: string;

i,n,j: integer;

begin

readln(s);

while (pos('anh',s)<>0) do

begin

insert('e^%%%%^%m',s,pos('anh',s));

delete(s,pos('anh',s),3);

end;

while (pos('em',s)<>0) do

begin

insert('anh',s,pos('em',s));

delete(s,pos('em',s),2);

end;

for i:=1 to length(s) do

if not(s[i] = '%') and not(s[i]='^') then write(s[i]);

readln

end.

Chúc bạn học tốt