#include <iostream> #include <cmath> using namespace std; bool isNarcissus(int i) { int number = i; int n = number; int pos = 0; while(n != 0) { n/=10; ++pos; } int sum = 0; sum+=pow(number%10,pos); sum+=pow(number/10%10,pos); sum+=pow(number/100,pos); if(sum == number) { return true; } else { return false; } } int main() { // write your code here...... for(int i=100;i<1000;i++) { if(isNarcissus(i)) { cout<<i<<endl; } } return 0; }