Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strings"
- )
- func main() {
- var n int
- fmt.Scanln(&n)
- spaces := 2 * n - 2
- stars := 2
- for row := 0; row < n; row++ {
- fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
- spaces -= 2
- stars += 2
- }
- spaces = 2
- stars = 2 * n - 2
- for row := 0; row < 2; row++ {
- fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
- spaces += 2
- stars -= 2
- }
- spaces = 2
- stars = 2 * n - 2
- for row := 0; row < 2; row++ {
- fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
- if spaces > 0 && stars > 0 {
- spaces -= 2
- stars += 2
- }
- }
- spaces = 2
- stars = 2 * n - 2
- for row := 0; row < 2; row++ {
- fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
- spaces += 2
- stars -= 2
- }
- spaces = 2
- stars = 2 * n - 2
- for row := 0; row < 2; row++ {
- fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
- if spaces > 0 && stars > 0 {
- spaces -= 2
- stars += 2
- }
- }
- spaces = 2
- stars = 2 * n - 2
- for row := 0; row < n; row++ {
- fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
- spaces += 2
- stars -= 2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement