12.5.13. Ispisati trocifrene Avogadrove brojeve
(371=33 + 73 + 13).
Opis rješenja:
Za objašnjenje:
*** |
Listing programa |
Opis |
1 |
PROGRAM p12500013; |
|
2 |
USES WinCRT; |
|
3 |
VAR
|
|
4 |
i,j,k,p: Integer; |
|
5 |
BEGIN |
|
6 |
FOR i:=1 TO 9 DO |
|
7 |
FOR j:=0 TO 9 DO |
|
8 |
FOR k:=0 TO 9 DO |
|
9 |
BEGIN |
|
10 |
p := i*100 + j * 10 + k; |
|
11 |
IF i*i*i+j*j*j+k*k*k=p THEN
|
|
12 |
Writeln(p); |
|
13 |
END; |
|
14 |
END. |
|
Listing programa:
PROGRAM p12500013;
USES WinCRT;
VAR
i,j,k,p: Integer;
BEGIN
Writeln('Trocifreni Avogadrovi brojevi');
FOR i:=1 TO 9 DO
FOR j:=0 TO 9 DO
FOR k:=0 TO 9 DO
BEGIN
p:=i*100+j*10+k;
IF i*i*i+j*j*j+k*k*k=p THEN
Writeln(p);
END;
END.
Ispis na ekranu:
Index
|
|