Thứ Hai, 3 tháng 12, 2012

program so_amstrong;
uses crt;
var i,so,p,b,j,bx:integer;
s:string;
begin

CLRSCR;

writeln ('tim so amstrong');
writeln ('nhap so bat ki');
...

for i:=1 to maxint do
begin
so:=i;
p:=0;
str (i,s);
repeat
b:=so mod 10; so:= so div 10;
bx:=b;
for j:=2 to length (s) do
bx:=bx*b;
p:=p+bx;
until so=0;
if p=i then write (i,'':3);
end;
readln;
end.

Không có nhận xét nào:

Đăng nhận xét