public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for(int i = 0;i<=n;i++) {
int count = 0;
int tmp = i;
while(tmp!=0) {
count++;
tmp = tmp/10;
}
tmp = i;
int sum = 0;
while(tmp!=0) {
sum + = Match.pow(tmp%10,count);
tmp/=10;
}
if(sum==i) {
System.out.println(i);
}
}
}
用Java求0-9999的水仙花数
最新推荐文章于 2024-08-18 21:36:31 发布