Advertisement
Spocoman

Sublime Logo

Oct 13th, 2024
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.44 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "strings"
  6. )
  7.  
  8. func main() {
  9.     var n int
  10.     fmt.Scanln(&n)
  11.    
  12.     spaces := 2 * n - 2
  13.     stars := 2
  14.  
  15.     for row := 0; row < n; row++ {
  16.         fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
  17.         spaces -= 2
  18.         stars += 2
  19.     }
  20.  
  21.     spaces = 2
  22.     stars = 2 * n - 2
  23.  
  24.     for row := 0; row < 2; row++ {
  25.         fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
  26.         spaces += 2
  27.         stars -= 2
  28.     }
  29.  
  30.     spaces = 2
  31.     stars = 2 * n - 2
  32.  
  33.     for row := 0; row < 2; row++ {
  34.         fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
  35.         if spaces > 0 && stars > 0 {
  36.             spaces -= 2
  37.             stars += 2
  38.         }
  39.     }
  40.  
  41.     spaces = 2
  42.     stars = 2 * n - 2
  43.  
  44.     for row := 0; row < 2; row++ {
  45.         fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
  46.         spaces += 2
  47.         stars -= 2
  48.     }
  49.  
  50.     spaces = 2
  51.     stars = 2 * n - 2
  52.  
  53.     for row := 0; row < 2; row++ {
  54.         fmt.Println(strings.Repeat(" ", spaces) + strings.Repeat("*", stars))
  55.         if spaces > 0 && stars > 0 {
  56.             spaces -= 2
  57.             stars += 2
  58.         }
  59.     }
  60.  
  61.     spaces = 2
  62.     stars = 2 * n - 2
  63.  
  64.     for row := 0; row < n; row++ {
  65.         fmt.Println(strings.Repeat("*", stars) + strings.Repeat(" ", spaces))
  66.         spaces += 2
  67.         stars -= 2
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement