Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool suma(int cifra){
- int sumaBroja = 0;
- int bazaCifra = cifra;
- while(cifra != 0)
- {
- int temp = cifra%10;
- sumaBroja += (temp*temp*temp);
- cifra /= 10;
- }
- if(sumaBroja == bazaCifra) return true;
- return false;
- }
- void ispis(int broj){
- for(int i = 1; i < broj; i++)
- if(suma(i)) cout << i << endl;
- }
- int main()
- {
- int a = 0;
- cout << "Unesi prirodan broj: ";
- for(;;){
- cin >> a;
- if(a < 0 || a > 200) cout << "Pogresan unos!" << endl << "Unesi ponovo: ";
- else break;
- }
- ispis(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement