#pattern exercise

10 messages · Page 1 of 1 (latest)

low ravine
#

It's almost certainly just a one-off error. It's likely the case that one of your <= needs to be a <

noble meadow
#

import "fmt"

func main() {
    var n int
    fmt.Println("Inserisci un numero intero: ")
    fmt.Scan(&n)
    if n < 1 {
        fmt.Println("Spiacente, il numero inserito è < di 1")
    }
    for row := 1; row <= n*2; row++ {
        for col := 1; col < n*2; col++ {
            if row == 1 && col < n || row == n*2 && col > n || col == n || row > n && row == col || row < n && row == col {
                fmt.Printf("*")
            } else {
                fmt.Printf(" ")
            }
        }
        fmt.Println()
    }
}```
#

with the following code the moment I've tried it

#
 *  *
  * *
   **
    *
    **
    * *
    *  *
    *   *
    *****```
#

this is the result

#

in the second triangle

#

it doesn't touch with the bottom

dreamy cedar
#

There's two singular asterisks in the middle, not one