limun11

Untitled

Sep 19th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. /*Napišite program, poštujući sve faze procesa programiranja, koji ispisuje sve troznamenkaste brojeve koji imaju svojstvo ABC=sqrtAB– C2.*/
  2.  
  3. Upotrijebite funkcije:
  4. bool provjera (int);
  5. Ispis troznamenkastih brojeva koji zadovoljavaju uvjet vršiti u funkciji main.
  6.  
  7.  
  8. #include<iostream>
  9. #include <cmath>
  10.  
  11. using namespace std;
  12.  
  13. bool provjera(int);
  14.  
  15. int main()
  16. {
  17.     int n;
  18.         for (int i = 100; i <= 999; i++)
  19.         if (provjera(i)==true)
  20.             cout << "Uvjet zadovoljavaju: " << provjera(i) << endl;
  21.     system("PAUSE");
  22.     return 0;
  23. }
  24.  
  25. bool provjera(int n)
  26. {
  27.     int suma, a, b;
  28.     b = n % 10;
  29.     a = n / 10;
  30.  
  31.     suma = sqrt(a) - pow(b, 2);
  32.  
  33.     if (suma == n)
  34.         return true;
  35.     return false;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment