intnarcissistic( int number ); voidPrintN( int m, int n );
intmain() { int m, n;
scanf("%d %d", &m, &n); if ( narcissistic(m) ) printf("%d is a narcissistic number\n", m); PrintN(m, n); if ( narcissistic(n) ) printf("%d is a narcissistic number\n", n);
#include<stdio.h> #include<math.h> intnarcissistic( int number ); voidPrintN( int m, int n );
intmain() { int m, n;
scanf("%d %d", &m, &n); if ( narcissistic(m) ) printf("%d is a narcissistic number\n", m); PrintN(m, n); if ( narcissistic(n) ) printf("%d is a narcissistic number\n", n);
return0; } intnarcissistic( int number ){ int i=0,k,sum=0,s; int a[999]; s=number; do { i++; a[i]=number%10; number=number/10; } while(number!=0); k=i; do { sum=sum+pow(a[i],k); i--; } while(i>0); if(sum==s) return1; else return0; } voidPrintN( int m, int n ){ int i,k,z; for(i=m+1;i<n;i++) if(narcissistic(i)==1) printf("%d\n",i); }