12.5.15. Napisati PROGRAM kojim se štampaju svi trocifreni brojevi abc koji imaju svojstvo
(abc)=(ab)2-c2 (147=142-72).
Za objašnjenje:
*** |
Listing programa |
Opis |
1 |
PROGRAM p12500015; |
|
2 |
USES WinCRT; |
|
3 |
VAR |
|
4 |
a,b,c: Integer; |
|
5 |
BEGIN |
|
6 |
FOR a:=1 TO 9 DO |
|
7 |
FOR b:=0 TO 9 DO |
|
8 |
FOR c:=0 TO 9 DO |
|
9 |
IF SQR(a*10+b)-SQR(c)=a*100+b*10+c THEN |
|
10 |
Writeln(a*100+b*10+c); |
|
11 |
END. |
|
Listing programa:
PROGRAM p12500015;
USES WinCRT;
VAR
a,b,c: Integer;
BEGIN
FOR a:=1 TO 9 DO
FOR b:=0 TO 9 DO
FOR c:=0 TO 9 DO
IF SQR(a*10+b)-SQR(c)=a*100+b*10+c THEN
Writeln(a*100+b*10+c);
END.
Ispis na ekranu:
Index
|
|