viet chuong trinh nhap vao mot so nguyen duong n va thuc hien ,so nguyen duong n co bao nhieu chu so,tinh tong cac so n va in ra man hinh cac so lon hon n
viet chuong trinh nhap vao mot so nguyen duong n va thuc hien ,so nguyen duong n co bao nhieu chu so,tinh tong cac so n va in ra man hinh cac so lon hon n
uses crt;
y:integer;
st:string;
begin
clrscr;
repeat
until n>0;
str(n,st);
d:=length(st);
t:=0;
max:=0;
for i:=1 to d do
t:=t+x;
max<x then max:=x;
end;
readln
end
uses crt;
var n,d,i,t,max,x:longint;
y:integer;
st:string;
begin
clrscr;
repeat
write(‘Nhap n=’); readln(n);
until n>0;
str(n,st);
d:=length(st);
writeln(‘So chu so cua ‘,n,’ la: ‘,d);
t:=0;
max:=0;
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+x;
if max<x then max:=x;
end;
writeln(‘Tong cac chu so cua ‘,n,’ la: ‘,t);
writeln(‘Chu so lon nhat cua ‘,n,’ la: ‘,max);
readln;
end.
mình có thử và không thấy mắc lỗi nên bạn thử xem