for number in 100...999{
var hunder = number / 100
var ten = number / 10 % 10
var num = number % 10
let sum = pow(Decimal(hunder), 3) + pow(Decimal(ten), 3) + pow(Decimal(num), 3)
if sum == Decimal(number){
print(number)
}
}
for number in 100...999{
var hunder = number / 100
var ten = number / 10 % 10
var num = number % 10
let sum = pow(Decimal(hunder), 3) + pow(Decimal(ten), 3) + pow(Decimal(num), 3)
if sum == Decimal(number){
print(number)
}
}
本文标题:水仙花数->Swift
本文链接:https://www.haomeiwen.com/subject/pdaavxtx.html
网友评论