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)
- var inDashes, outDashes, border string
- for i := 0; i < n / 2 + (n % 2); i++ {
- outDashes = strings.Repeat("-", (n - 1) / 2 - i)
- border = "*"
- if i == 0 {
- if n % 2 == 0 {
- border = "**"
- }
- fmt.Println(outDashes + border + outDashes)
- } else {
- inDashes = strings.Repeat("-", i * 2)
- if n % 2 == 1 {
- inDashes = strings.Repeat("-", i * 2 - 1)
- }
- fmt.Println(outDashes + border + inDashes + border + outDashes)
- }
- }
- for i := n / 2 - (1 + (n - 1) % 2); i >= 0; i-- {
- outDashes = strings.Repeat("-", (n - 1) / 2 - i)
- border = "*"
- if i == 0 {
- if n % 2 == 0 {
- border = "**"
- }
- fmt.Println(outDashes + border + outDashes)
- } else {
- inDashes = strings.Repeat("-", i * 2)
- if (n % 2 == 1) {
- inDashes = strings.Repeat("-", i * 2 - 1)
- }
- fmt.Println(outDashes + border + inDashes + border + outDashes)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement