Advertisement
TareSedam

Untitled

Feb 14th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int BrojCifara(int n) {
  4. int brojac = 0;
  5. do {
  6. n /= 10;
  7. brojac++;
  8. } while (n != 0);
  9. return brojac;
  10. }
  11. bool Suma(int n) {
  12. int ost = 0;
  13. int br = BrojCifara(n);
  14. int s = 0;
  15. int kopija = n;
  16. do {
  17. ost = kopija % 10;
  18. kopija /= 10;
  19. br++;
  20. s += pow(ost, br);
  21. } while (kopija != 0);
  22. if (s == n)
  23. return true;
  24. return false;
  25. }
  26.  
  27. void main() {
  28. int n;
  29. cout << "Unesi:" << endl;
  30. do {
  31. cin >> n;
  32. if (Suma(n == true))
  33. cout << "Jeste AB." << endl;
  34. else
  35. cout << "NIJE." << endl;
  36. } while (n > 0);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement