耗时4个小时,尽管过程是曲折的,deepseek都分析不明白了,哈哈哈。但是结果可以运行出来真🍰😁真🍰😁#include<stdio.h>
//水仙花数
int main(){
int n;
scanf("%d",&n);
if(n<3||n>7){
printf("n不在3和7之间");
return 1;
}
int count=n;
int start=1,end=1;
while (count>1){
start*=10;//如果n=3,最终start为100
end=start*10;//end为1000
count--;
}
count=1;
int i=start;
for(i;i<end;i++){
int a=i;
int sum=0;
while(a>0){
int m=a%10;
int b=m;
while(count<n){
b*=m;
count++;
}
count=1;
sum+=b;
a=a/10;
}
if(sum==i){
printf("%d\n",sum);
}
}
return 0;
}

