Câu a:
uses crt;
var n:longword;
s:string;
BEGIN
clrscr;
write('Nhap n:'); readln(n);
str(n,s);
write('So ',n,' co ',length(s),' chu so.');
readln
END.
Câu b:
uses crt;
var n:longword;
s:string;
i,tam:byte;
tong:integer;
BEGIN
clrscr;
write('Nhap n:'); readln(n);
str(n,s);
tong:=0;
for i:=1 to length(s) do
begin
val(s[i],tam);
tong:=tong+tam;
end;
write('Tong cac chu so cua so ',n,' la ',tong,'.');
readln
END.
Câu c:
uses crt;
var n:longword;
s:string;
i:byte;
BEGIN
clrscr;
write('Nhap n:'); readln(n);
str(n,s);
write('So doi xung cua ',n,' la :');
for i:=length(s) downto 1 do
write(s[i]);
readln
END.
Câu d:
uses crt;
var a,b,tong:longword;
s1,s2:string;
i:byte;
BEGIN
clrscr;
write('Nhap a:'); readln(a);
write('Nhap b:'); readln(b);
str(a,s1); s2:='';
for i:=length(s1) downto 1 do
s2:=s2+s1[i];
val(s2,a);
str(b,s1); s2:='';
for i:=length(s1) downto 1 do
s2:=s2+s1[i];
val(s2,b);
tong:=a+b;
str(tong,s1);
write('Tong doi xung cua hai so a va b la:');
for i:=length(s1) downto 1 do
write(s1[i]);
readln
END.
Chúc bạn học tốt.
Nếu đúng thì cho mình câu trl hay nhất nha.