55 lines
805 B
Go
55 lines
805 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/fatih/color"
|
|
)
|
|
|
|
var x int
|
|
var y int
|
|
|
|
type Coordinates struct {
|
|
X, Y int
|
|
}
|
|
|
|
func getMatrix(mat [][]string, c Coordinates) {
|
|
col := color.New(color.FgBlack).Add(color.Underline).Add(color.BgHiRed)
|
|
for i := range mat {
|
|
for i1 := range mat[i] {
|
|
if i == c.X && i1 == c.Y {
|
|
col.Printf("%v", mat[i][i1])
|
|
fmt.Printf(" ")
|
|
} else {
|
|
fmt.Printf("%v ", mat[i][i1])
|
|
}
|
|
}
|
|
fmt.Println()
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
matrix := make([][]string, 5)
|
|
for i := range matrix {
|
|
matrix[i] = make([]string, 5)
|
|
}
|
|
|
|
for i := range matrix {
|
|
for i1 := range matrix[i] {
|
|
matrix[i][i1] = "A"
|
|
}
|
|
}
|
|
fmt.Printf("X coordinate: ")
|
|
fmt.Scanln(&x)
|
|
|
|
fmt.Printf("Y coordinate: ")
|
|
fmt.Scanln(&y)
|
|
|
|
x--
|
|
y--
|
|
|
|
coords := Coordinates{x, y}
|
|
|
|
getMatrix(matrix, coords)
|
|
|
|
}
|