Program determine Armstrong's numbers
Delphi & Pascal (česká wiki)
Category: Homework in Pascal
Program: Arm_cis2.pas
File exe: Arm_cis2.exe
File ubuntu: Arm_cis2
Program: Arm_cis2.pas
File exe: Arm_cis2.exe
File ubuntu: Arm_cis2
Program determine Armstrong's numbers.
{ ARM_CIS2.PAS } { Program zisti Armstrongove cisla zo zadaneho cisla. } { Upravena verzia arm_cisl.pas } { } { Author: cipa } { Date : 29.01.2008 http://www.trsek.com } uses SysUtils,Math; var number,i,i_1,zvysok,number_1 : integer; dlzka_retazca : integer; spolu,mocnina: Extended; Convert_To_String : string; begin writeln('Armstrongove cisla.'); writeln('-------------------'); write('Zadaj cislo: '); readln(number); For i := 1 To number Do begin Str(i,Convert_To_String); dlzka_retazca := length(Convert_To_String); number_1 := i; spolu := 0; For i_1 := 1 To dlzka_retazca Do begin zvysok := number_1 mod 10; number_1 := number_1 div 10; mocnina := Power(zvysok ,dlzka_retazca); spolu := spolu + mocnina; IF i_1 = dlzka_retazca THEN begin IF spolu = i THEN begin writeln('Cislo ',i,' je Armstrongove cislo'); end; end; end; end; readln; end.