可就是不成功,目标文件内容始终只有:1 4 5 帮忙调试一下,谢谢
set f1 [open "c:/data.txt"]
set f2 [open "c:/result.txt" w]
set i 0
while {![eof $f1]} {
gets $f1 a($i)
incr i
}
incr i -1
for {set b 0} {$b<=[expr [llength a(0)]-1]} {incr b} {
for {set c 0} {$c<=$i} {incr c} {
lappend h [lindex $a($c) $b]
}
puts $f2 $h
set h ""
}
close $f1
close $f2
set f1 [open "d:/data.txt"]
set f2 [open "d:/result.txt" w]
set i 0
while {![eof $f1]} {
gets $f1 a($i)
incr i
}
incr i -1
for {set b 0} {$b<=[expr [llength $a(0)]-1]} {incr b} {
for {set c 0} {$c<=$i} {incr c} {
lappend h [lindex $a($c) $b]
}
puts $f2 $h
set h ""
}
close $f1
close $f2
可以呀