Program determine Armstrong's numbers

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: Homework in Pascal

Author: Juraj Pupák
Program: Arm_cisl.pas
File exe: Arm_cisl.exe
File ubuntu: Arm_cisl

Program determine Armstrong's numbers.
{ ARM_CISL.PAS                                                      }
{ Program zisti Armstrongove cisla zo zadaneho cisla.               }
{                                                                   }
{ Author: Juraj Pupak                                               }
{ Date  : 27.10.2006                           http://www.trsek.com }
 
program Armstrongove_Cisla;
uses crt;
  var
    number,i,i_1,zvysok,number_1,i_2,mocnina : integer;
    dlzka_retazca,spolu : integer;
    Convert_To_String : string;
begin
  clrscr;
  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  := zvysok * zvysok * zvysok;
          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.