mirror of https://github.com/01-edu/public.git
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.
41 lines
579 B
41 lines
579 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
5 years ago
|
"fmt"
|
||
5 years ago
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func solve(x, y int) {
|
||
|
for i := 0; i < x; i++ {
|
||
|
line := ""
|
||
|
for j := 0; j < y; j++ {
|
||
5 years ago
|
if i%2 == 0 && j%2 == 0 {
|
||
5 years ago
|
line += "#"
|
||
5 years ago
|
} else if i%2 == 0 && j%2 == 1 {
|
||
5 years ago
|
line += " "
|
||
5 years ago
|
} else if i%2 == 1 && j%2 == 1 {
|
||
5 years ago
|
line += "#"
|
||
|
} else {
|
||
|
line += " "
|
||
|
}
|
||
|
}
|
||
5 years ago
|
fmt.Println(line)
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
args := os.Args[1:]
|
||
|
if len(args) != 2 {
|
||
5 years ago
|
fmt.Println("Error")
|
||
5 years ago
|
return
|
||
|
}
|
||
|
x, _ := strconv.Atoi(args[1])
|
||
|
y, _ := strconv.Atoi(args[0])
|
||
|
if x <= 0 || y <= 0 {
|
||
5 years ago
|
fmt.Println("Error")
|
||
5 years ago
|
} else {
|
||
|
solve(x, y)
|
||
5 years ago
|
}
|
||
|
}
|