Bài 3:
Program bai1;
uses crt;
var a,i,s,t,code:longint;
st:string;
Begin
clrscr;
write('Nhap a:'); readln(a);
str(a,st);
for i:=1 to Length(st) do
begin
Val(st[i],t,code);
s:=s+t;
end;
writeln('Tong cac chu so cua ',a,':',s);
readln;
End.
Bài 1:
Program bai1;
uses crt;
var a,b,c:integer;
Begin
clrscr;
for a:=1 to 9 do
for b:=0 to 9 do
for c:=0 to 9 do
if a*b*c=a+b+c then write(a,b,c,' ');
readln;
End.
Bài 2:
Program bai1;
uses crt;
var a:longint;
st:string;
Begin
clrscr;
write('Nhap a:'); readln(a);
str(a,st);
write('So chu so cua ',a,':',Length(st));
readln;
End.