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" "fmt"
) )
var cell string = "x"
var x int
var y int
func main() { func main() {
a := [][]int{ a := [][]string{
{0, 1, 2}, {cell, cell, cell},
{3, 4, 5}, {cell, "1", cell},
{6, 7, 8}, {cell, cell, cell},
} }
for i := 0; i < len(a); i++ { for i := 0; i < len(a); i++ {
@ -17,4 +21,15 @@ func main() {
} }
fmt.Println() 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])
} }