Uses crt;
var st: string;
function KT (xau: string): boolean;
var i, dem: integer;
begin
dem:=0;
for i:= 1 to length(st) div 2 do
if xau<>xau[length(xau)-i+1] then inc(dem);
if dem<>0 then KT:=False else KT:=True;
end;
begin
clrscr;
write ('Nhap so co do dai khong qua 100 chu so: '); readln (st);
if length(st)>100 then
begin
write ('Nhap khong hop le! An Enter va chay lai!');
readln; exit;
end;
if KT(st)=True then write ('Day la so doi xung!') else write ('Day la so khong doi xung!');
readln
end.
procedure bai1;
var
n,n1,temp:integer;
BEGIN
repeat
clrscr;
write('Nhap vao so n=');
readln(n);
if((n>-32000) and (n<32000) )then break;
until (1=1);
n1:=0;
temp:=n;
while temp>0 do
begin
n1:=n1*10 + temp mod 10;
temp:= temp div 10;
end;
if n1=n then writeln('Doi xung')
else
writeln('Khong doi xung');
END;
Function sdx (l:longint):boolean;
var s:string;
i,m:longint;
Begin
sdx:=false;
str(l,s);
m:=length(s);
for i:= 1 to m div 2 do
if s[i]=s[m-i+1] then
sdx:=true
else
sdx:=false;
End;
Procedure sodoixung(var a:mat);
Begin
write('cac so doi xung la: ');
for i:= 1 to n do
if sdx(a[i]) then
write(a[i]:4);
End;
Còn phần mảng bạn tự làm nha