// No.82 市松模様 package main import ( "fmt" "strings" ) func main() { const black = "B" const white = "W" var w, h int var c string fmt.Scan(&w, &h, &c) var pair1, pair2 string if c == black { pair1 = black + white pair2 = white + black } else { pair1 = white + black pair2 = black + white } var line string for i := 0; i < h; i++ { // 模様の決定 if i%2 == 0 { line = pair1 } else { line = pair2 } // 列数の決定 if w%2 == 0 { fmt.Println(strings.Repeat(line, int(w/2))) } else { fmt.Println(strings.Repeat(line, int(w/2)) + string(line[0])) } } }