Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,27 @@
package main
import "fmt"
func main() {
floyd(5)
floyd(14)
}
func floyd(n int) {
fmt.Printf("Floyd %d:\n", n)
lowerLeftCorner := n*(n-1)/2 + 1
lastInColumn := lowerLeftCorner
lastInRow := 1
for i, row := 1, 1; row <= n; i++ {
w := len(fmt.Sprint(lastInColumn))
if i < lastInRow {
fmt.Printf("%*d ", w, i)
lastInColumn++
} else {
fmt.Printf("%*d\n", w, i)
row++
lastInRow += row
lastInColumn = lowerLeftCorner
}
}
}