Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int power(int x, int i) {
- if (i == 0) return 1;
- int xx = 1;
- for (int j = 0; j < i; j++) {
- xx = xx * x;
- }
- return xx;
- }
- int main()
- {
- int a = 0, b = 0;
- cout << "Armstrong's numbers in ";
- cout << "Range: ["; cin >> a; cout << ";"; cin >> b; cout << "]" << endl;
- cout << "Armstong's numbers in this range:" << endl;
- for (int i = a; i <= b; i++) {
- int container = 0;
- int ii = i;
- while (ii > 0) {
- container += power(ii % 10, 3);
- ii = ii / 10;
- }
- if (i == container) {
- cout << i << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement