for 循环是一种重复控制结构,可让您有效地编写需要执行特定次数的代码。
Tcl语言中 for 循环的语法为-
for {initialization} {condition} {increment} { statement(s); }
#!/usr/bin/tclsh # for循环执行 for { set a 10} {$a < 20} {incr a} { puts "value of a: $a" }
编译并执行上述代码后,将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/tcl-tk/tcl-for-loop.html
来源:LearnFk无涯教程网
value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 15 value of a: 16 value of a: 17 value of a: 18 value of a: 19
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)