我的代码输出1~7位水仙花数,为啥我3位和4位能输出,5,6,7都不能输出,求解。。。
[color=#000000][/color]
#include<stdio.h>
int main()
{int N;
scanf("%d",&N);
if(N==3)
{
for(int m=100;m<1000;m++)
{int a,b,c;
a=m%10;
b=m/100;
c=m/10%10;
if(m==a*a*a+b*b*b+c*c*c)
printf("%d\n",m);
}
}
else
if(N==4)
{
for(int m=1000;m<10000;m++)
{
int a,b,c,d;
a=m%10;
b=m/100%10;
c=m/1000;
d=m/10%10;
if(m==a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d)
printf("%d\n",m);
}
if(N==5)
{
for(int m=10000;m<100000;m++)
{
int a,b,c,d,e;
a=m%10;
b=m/100%10;
c=m/1000%10;
d=m/10%10;
e=m/10000;
m++;
if(m==a*a*a*a*a+b*b*b*b*b+c*c*c*c*c+d*d*d*d*d+e*e*e*e*e)
printf("%d\n",m);
}
}
if(N==6)
{
for(int m=100000;m<1000000;m++)
{
int a,b,c,d,e,f;
a=m%10;
b=m/100%10;
c=m/1000%10;
d=m/10%10;
e=m/10000%10;
f=m/100000;
m++;
if(m==a*a*a*a*a*a+b*b*b*b*b*b+c*c*c*c*c*c+d*d*d*d*d*d+e*e*e*e*e*e+f*f*f*f*f*f)
printf("%d\n",m);
}
}
if(N==7)
{
for(int m=1000000;m<10000000;m++)
{
int a,b,c,d,e,f,g;
a=m%10;
b=m/100%10;
c=m/1000%10;
d=m/10%10;
e=m/10000%10;
f=m/100000%10;
g=m/1000000;
m++;
if(m==a*a*a*a*a*a*a+b*b*b*b*b*b*b+c*c*c*c*c*c*c+d*d*d*d*d*d*d+e*e*e*e*e*e*e+f*f*f*f*f*f*f+g*g*g*g*g*g*g)
printf("%d\n",m);
}
}
}
}