Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int BrojCifara(int n) {
- int brojac = 0;
- do {
- n /= 10;
- brojac++;
- } while (n != 0);
- return brojac;
- }
- bool Suma(int n) {
- int ost = 0;
- int br = BrojCifara(n);
- int s = 0;
- int kopija = n;
- do {
- ost = kopija % 10;
- kopija /= 10;
- br++;
- s += pow(ost, br);
- } while (kopija != 0);
- if (s == n)
- return true;
- return false;
- }
- void main() {
- int n;
- cout << "Unesi:" << endl;
- do {
- cin >> n;
- if (Suma(n == true))
- cout << "Jeste AB." << endl;
- else
- cout << "NIJE." << endl;
- } while (n > 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement