Added guessing coordinates to matrix exercise

This commit is contained in:
raul 2024-02-29 06:50:39 +01:00
parent 9e45c522c8
commit 38fe54f3de
1 changed files with 20 additions and 5 deletions

View File

@ -4,11 +4,15 @@ import (
"fmt"
)
var cell string = "x"
var x int
var y int
func main() {
a := [][]int{
{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
a := [][]string{
{cell, cell, cell},
{cell, "1", cell},
{cell, cell, cell},
}
for i := 0; i < len(a); i++ {
@ -17,4 +21,15 @@ func main() {
}
fmt.Println()
}
fmt.Printf("Where's the one?\n")
fmt.Printf("X coordinate: ")
fmt.Scanln(&x)
fmt.Printf("Y coordinate: ")
fmt.Scanln(&y)
x++
y++
fmt.Println(a[x][y])
}