golang-exercises/matrix/main.go

36 lines
445 B
Go
Raw Normal View History

2024-02-25 07:34:27 +01:00
package main
import (
"fmt"
)
var cell string = "x"
var x int
var y int
2024-02-25 07:34:27 +01:00
func main() {
a := [][]string{
{cell, cell, cell},
{cell, "1", cell},
{cell, cell, cell},
2024-02-25 07:34:27 +01:00
}
for i := 0; i < len(a); i++ {
for _, v := range a[i] {
fmt.Printf("%v ", v)
2024-02-25 07:34:27 +01:00
}
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])
2024-02-25 07:34:27 +01:00
}