adnanj

Trocifreni brojevi koji imaju svojstvo ABC=(AB)^2-C^2

Aug 28th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. /* Program ispisuje sve trocifrene brojeve koji imaju svojstvo: ABC=(AB)^2-C^2. Na primjer, 147=14^2-7^2. */
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. bool provjera(int broj)
  7. {
  8.     return broj == pow(broj / 10, 2) - pow(broj % 10, 2);
  9. }
  10.  
  11. void main()
  12. {
  13.     cout << "Trocifreni brojevi koji imaju svojstvo: ABC=(AB)^2-C^2: " << endl;
  14.     for (int i = 100; i <= 999; i++)
  15.         if (provjera(i))
  16.            cout << i << endl;
  17.  
  18.     system("pause>0");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment