package main import fmt func main const size int 12 fmt Print for size

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"fmt"
)
func main() {
const size int = 12
fmt.Print(" x |")
for i := 1; i <= size; i++ {
fmt.Printf("%4d", i)
}
fmt.Print("\n---+")
for i := 1; i <= size; i++ {
fmt.Print("----")
}
for j := 1; j <= size; j++ {
fmt.Printf("\n%2d |", j)
for i := 1; i <= size; i++ {
if i >= j {
fmt.Printf("%4d", i*j)
} else {
fmt.Print(" ")
}
}
}
fmt.Println("")
}