lesson9 :for循环的学习

 

for {puts "Start"; set i 0} {$i < 2} {incr i; puts "I after incr: $i"; } {
puts "I inside first loop: $i"
}

//和c一样 有三个条件

;# Because the test is evaluated before the body,
;# this loop won't execute the body of the code.

for {puts "Start"; set i 3} {$i < 2} {incr i; puts "I after incr: $i"; } {
puts "I inside second loop: $i"
}
//不符合条件 直接结束For循环

;# A while loop equivalent to the first for loop:

puts "Start"; set i 0;
while {$i < 2} {
puts "I inside first loop: $i"
incr i;
puts "I after incr: $i";
}

//while 中的 incr用法

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-05-14
  • 2021-06-08
  • 2022-12-23
  • 2021-05-15
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-12-01
  • 2021-11-21
  • 2022-12-23
  • 2021-10-25
相关资源
相似解决方案