limun11

Untitled

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