ios – 关于控制流实验的Swift编程语言手册章节

前端之家收集整理的这篇文章主要介绍了ios – 关于控制流实验的Swift编程语言手册章节前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在完成本书的第一章,无法弄清楚实验:

Add another variable to keep track of which kind of number was the
largest,as well as what that largest number was.

这是本书的代码

let interstingNumbers = [
"Prime": [2,3,5,7,11,13,17],"Fibonacci": [1,1,2,8],"Square": [1,4,9,16,25,36],]
var largest = 0
for (kind,numbers) in interstingNumbers {
    for number in numbers {
        if number > largest {
            largest = number
        }
    }
}
largest

解决方法

所以基本上你想要在将数字放入最大值的同时将其放在某处,例如变成一个名为largestKind的变量.
原文链接:https://www.f2er.com/iOS/334809.html

猜你在找的iOS相关文章