#-*- coding: utf-8-*-import timeimport math#获取3位数的水仙花数start1 = time.time()start = time.time() numbers = []for i in range(100,1000): a = i % 10 b = i // 10 % 10 c = i // 100 if((a ** 3) + (b ** 3) + (c ** 3)) == i: numbers.append(i) for j in numbers:…
什么是水仙花数? 水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153). 代码1: #include<stdio.h> int main() { int m,a, b, c; m = ; printf("1000以内水仙花数为:\n"); ) { a = m / ; b = m / % ; c = m % ; if (m == a * a * a + b * b * b + c * c * c) print…
#include <stdio.h> int fun(int x) { int a, b, c; a = x / ; b = x % / ; c = x % ; if (x == a * a * a + b * b * b + c * c * c) ; else ; } int main() { int m; printf("1000以内的水仙花数:\n"); ; m < ; m++) { ) printf("%5d\n", m); } }…
百位数的立方 + 十位数的立方 +个位数的立方 = 原数 for m in range(1,10): for n in range(0,10): for i in range(0,10): a = m*100 + n*10 + i if a == m**3 + n**3 +i**3: print(a) 或 for i in range(100,1000): ge = i % 10 shi = i // 10 % 10 bai = i // 100 if ge ** 3 + shi ** 3 +…