Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Floyds-triangle/Tcl/floyds-triangle.tcl
Normal file
19
Task/Floyds-triangle/Tcl/floyds-triangle.tcl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
proc floydTriangle n {
|
||||
# Compute the column widths
|
||||
for {set i [expr {$n*($n-1)/2+1}]} {$i <= $n*($n+1)/2} {incr i} {
|
||||
lappend w [string length $i]
|
||||
}
|
||||
# Print the triangle
|
||||
for {set i 0; set j 1} {$j <= $n} {incr j} {
|
||||
for {set p -1; set k 0} {$k < $j} {incr k} {
|
||||
puts -nonewline [format "%*d " [lindex $w [incr p]] [incr i]]
|
||||
}
|
||||
puts ""
|
||||
}
|
||||
}
|
||||
|
||||
# Demonstration
|
||||
puts "Floyd 5:"
|
||||
floydTriangle 5
|
||||
puts "Floyd 14:"
|
||||
floydTriangle 14
|
||||
Loading…
Add table
Add a link
Reference in a new issue