uses crt; var s:string; i:longint; begin clrscr; write(‘Nhap xau: ‘); readln(s); while s[i]=#32 do delete(s,i,1); while s[length(s)]=#32 do delete(s,length(s),1); while pos(#32,s)<>0 do delete(s,pos(#32,s),1); writeln(‘Xau sau khi sua chua: ‘,s); readln end.
program xoa;
uses crt;
var s:string;
begin
clrscr;
write(‘Nhap xau: ‘); readln(s);
while pos(‘ ‘,s)<>0 do delete(s,pos(‘ ‘,s),1);
write(‘Xau sau khi xoa dau cach la: ‘,s);
readln;
end.
uses crt;
var s:string; i:longint;
begin
clrscr;
write(‘Nhap xau: ‘); readln(s);
while s[i]=#32 do delete(s,i,1);
while s[length(s)]=#32 do delete(s,length(s),1);
while pos(#32,s)<>0 do delete(s,pos(#32,s),1);
writeln(‘Xau sau khi sua chua: ‘,s);
readln
end.
————-
#32: tượng trưng cho ký hiệu khoảng trắng
* Bạn có thể thay #32 thành ‘ ‘