Thứ Hai, 3 tháng 12, 2012

đề 2: tìm số Amstrong

program bai2;

var i,so,p,b,bx,j,h:integer;
     s:string;
begin
writeln('nhao so');
 readln(so);
h:=so; p:=0; str(so,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=h then
 write(h,' la so amstrong ');
 readln;
 end.

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

Đăng nhận xét