You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
713 B

package correct
import (
"os"
"strconv"
"github.com/01-edu/z01"
)
func printLineCh(str string) {
for _, c := range str {
z01.PrintRune(c)
}
z01.PrintRune('\n')
}
func solve(x, y int) {
for i := 0; i < x; i++ {
line := ""
for j := 0; j < y; j++ {
if (i%2 == 0) && (j%2 == 0) {
line += "#"
} else if (i%2 == 0) && (j%2 == 1) {
line += " "
} else if (i%2 == 1) && (j%2 == 1) {
line += "#"
} else {
line += " "
}
}
printLineCh(line)
}
}
func main() {
args := os.Args[1:]
if len(args) != 2 {
printLineCh("Error")
return
}
x, _ := strconv.Atoi(args[1])
y, _ := strconv.Atoi(args[0])
if x <= 0 || y <= 0 {
printLineCh("Error")
return
}
solve(x, y)
}