bài 1:
uses crt;
var i:integer;
n,k,t,vt:longint;
kt:boolean;
begin
clrscr;
Write(' Nhap so n: '); Readln(n);
k:=n;
repeat
t:=t+(n-((n div 10)*10));
n:=n div 10;
until n mod 10=0;
if t-((t div 10 )*10)=9 then kt:=true
else kt:=false;
vt:=k-((k div 10)*10);
k:=k div 10;
repeat
if vt>(k-((k div 10)*10)) then kt:=true
else kt:=false;
k:=k div 10;
until (k mod 10 =0) or (kt= false);
if kt=true then writeln(' So may man')
else writeln(' Khong la so may man ');
readln;
end.
bài 2:
uses crt;
var n,i:integer;
c:string;
begin
clrscr;
write(' Nhap xau: '); Readln(c);
for i:= n to length(c) do
if c[i]= '#' then
begin
delete(c,i,1);
delete(c,(i-1),1);
end;
for i:= 1 to length(c) do write(c[i]);
readln;
end.
bài 3:
uses crt;
var a,b:array[1..100] of integer;
i,j,d:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write(' Nhap a[',i,']: '); Readln(a[i]);
end;
for i:=1 to 10 do
b[i]:=a[i]-((a[i] div 42)*42);
for i:=1 to 11 do
for j:=i+1 to 10 do
if b[i]=b[j] then inc(d);
writeln('co ',(10-d),' so du khac nhau');
readln;
end.
bài 4:
uses crt;
var n,tg,m,i,k:longint;
kq,y,c:string;
kt:boolean;
begin
clrscr;
write(' Nhap so nguyen he thap phan : '); Readln(n);
k:=n;
while n<>0 do
begin
tg:=n mod 2;
n:=n div 2;
str(tg,y);
kq:=y+kq;
end;
str(k,c);
for i:=1 to length(c) do
m:=length(c);
for i:=1 to m do
if (c[i]=c[m-i+1]) and (kq[i]=kq[m-i+1]) then
kt:=true;
if kt=true then write(' Dung ')
else write(' Sai ');
readln;
end.