Windows Powershell Do While 循环

22806 17 0 PDF 2021-01-30 23:01:39

继续与终止循环的条件 do-while()会先执行再去判断,能保证循环至少执行一次。 代码如下: PS C:Powershell> do { $n=Read-Host } while( $n -ne 0) 10 100 99 2012 世界末日 为什么不退出 因为条件不满足 怎样才能满足 请输入一个0,试一试 0 PS C:Powershell> 单独使用While 代码如下: $n=5 while($n -gt 0) { $n $n=$n-1 } 5 4 3 2 1 终止当前循环 使用continue关键字,可是终止当前循环,跳过continue后其它语句,重新下一次

用户评论
请输入评论内容
评分:
暂无评论