uses crt;
var n,d,dem,i,x,y,t:integer;
st:string;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1000<=n) and (n<=9999);
if n mod 2=0 then
begin
str(n,st);
d:=length(st);
dem:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if x=0 then inc(em);
end;
writeln('So chu so 0 co trong so ',n,' la: ',dem);
end
else begin
str(n,st);
t:=0;
d:=length(st);
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+sqr(x);
end;
writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);
end;
readln;
end.
uses crt;
var n,d,dem,i,x,y,t:integer;
st:string;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1000<=n) and (n<=9999);
if n mod 2=0 then
begin
str(n,st);
d:=length(st);
dem:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if x=0 then inc(em);
end;
writeln('So chu so 0 co trong so ',n,' la: ',dem);
end
else begin
str(n,st);
t:=0;
d:=length(st);
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+sqr(x);
end;
writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);
end;
readln;
end.