limun11

Untitled

Jan 23rd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool provjera(int);
  5. int main()
  6. {
  7.     int n = 999;
  8.     for (int i = 100; i <= n;i++)
  9.     {
  10.         if (provjera(i) == true)
  11.             cout << i << endl;
  12.     }
  13.  
  14.     system("PAUSE");
  15.     return 0;
  16. }
  17.  
  18. bool provjera(int n)
  19. {
  20.     int pohrana, x, x1, y, broj;
  21.     for (int i = 100; i <= n; i++)
  22.     {
  23.         pohrana = i % 10;
  24.         x = pohrana*pohrana;
  25.         broj = i / 10;
  26.         x1 = broj*broj;
  27.         y = x1 - x;
  28.         if (y == i)
  29.         {
  30.             return true;
  31.         }
  32.        
  33.     }
  34.    
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment