Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 斯威夫特a';对于循环';其中,指数可以增加X倍_Swift_For Loop - Fatal编程技术网

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)
}