Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool suma (int);
- void ispis (int);
- int main() {
- int n;
- do {
- cout << "Unesite prirodan broj n (ne veci od 200): ";
- cin >> n;
- } while(n <= 0 || n > 200);
- cout << "Brojevi koji su jednaki sumi kubova svojih cifri su: ";
- ispis(n);
- system("pause>0");
- return 0;
- }
- bool suma (int broj) {
- int suma = 0, tempBroj = broj;
- while(broj > 0) {
- suma += pow(broj%10, 3);
- broj /= 10;
- }
- if(suma == tempBroj) return true;
- return false;
- }
- void ispis (int n) {
- for(int i = 1; i <= n; i++)
- if(suma(i))
- cout << i << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment