Swift 斯威夫特a';对于循环';其中,指数可以增加X倍
我想知道在Swift 斯威夫特a';对于循环';其中,指数可以增加X倍,swift,for-loop,Swift,For Loop,我想知道在swift中是否有一种方法可以操作for循环上运行的索引 在程序运行时使用,应执行以下操作: var runIndex = 1 while runIndex <= 100000000 { print(runIndex) runIndex = runIndex * 10; } Swift模拟为: for (int runIndex=1; runIndex <= 100000000; runIndex = runIndex*10){ System.ou
swift
中是否有一种方法可以操作for循环上运行的索引
在程序运行时使用,应执行以下操作:
var runIndex = 1
while runIndex <= 100000000 {
print(runIndex)
runIndex = runIndex * 10;
}
Swift模拟为:
for (int runIndex=1; runIndex <= 100000000; runIndex = runIndex*10){
System.out.println(runIndex);
}
请参阅并注意,文档实际上以您自己的用例,即连续幂(2)为例 Swift模拟到:
for (int runIndex=1; runIndex <= 100000000; runIndex = runIndex*10){
System.out.println(runIndex);
}
请参阅并注意,文档实际上以您自己的用例,即连续幂(2)为例
for (int runIndex=1; runIndex <= 100000000; runIndex = runIndex*10){
System.out.println(runIndex);
}
var runIndex = 1
while runIndex <= 100000000 {
print(runIndex)
runIndex = runIndex * 10;
}
for runIndex in (sequence(first: 1) {$0 >= 100000000 ? nil : $0*10}) {
print(runIndex)
}