有问题可以留言交流哈
package main
import (
"fmt"
"math"
)
func main() {
var n float64
var c byte
_, _ = fmt.Scanf("%f %c", &n, &c)
height := int(math.Floor(n/2+0.5))
for j:=0; j<height; j++ {
for i:=0; i<int(n); i++ {
if j==0 || j==height-1 {
fmt.Printf("%c", c)
} else if i==0 || i==int(n)-1 {
fmt.Printf("%c", c)
} else {
fmt.Printf(" ")
}
}
fmt.Println()
}
}