#include <iostream>
using namespace std;
int main()
{
int nmr1, nmr2, i, num, digit, ttl;
cout<<"--------------------------------------------\n";
cout<<"- Angka Armstrong -\n";
cout<<"--------------------------------------------\n";
cout << " Masukan nomor pertama: ";
cin >> nmr1;
cout << " Masukan nomor kedua : ";
cin >> nmr2;
cout << " Angka Armstrong antara " << nmr1 << " dan " << nmr2 << " adalah: " << endl;
cout<<"--------------------------------------------\n";
for(i = nmr1; i <= nmr2; i++)
{
ttl = 0;
num = i;
for(; num > 0; num /= 10)
{
digit = num % 10;
ttl = ttl + digit * digit * digit;
}
if(ttl == i)
{
cout << i << endl;
}
}
cout<<"--------------------------------------------\n";
return 0;
}
More From Author
Algoritma dan Pemrograman