KiKi和BoBo玩 “井”字棋。也就是在九宫格中,只要任意行、列,或者任意对角线上面出现三个连续相同的棋子,就能获胜。请根据棋盘状态,判断当前输赢。
KiKi和BoBo玩 “井”字棋。也就是在九宫格中,只要任意行、列,或者任意对角线上面出现三个连续相同的棋子,就能获胜。请根据棋盘状态,判断当前输赢。
三行三列的字符元素,代表棋盘状态,字符元素用空格分开,代表当前棋盘,其中元素为K代表KiKi玩家的棋子,为O表示没有棋子,为B代表BoBo玩家的棋子。
如果KiKi获胜,输出“KiKi wins!”;
如果BoBo获胜,输出“BoBo wins!”;
如果没有获胜,输出“No winner!”。
K O B O K B B O K
KiKi wins!
zl=[input().split() for i in range(3)]
options=[[zl[i][j] for i in range(3) ] for j in range(3)]
options.extend([[zl[i][j] for j in range(3) ] for i in range(3)])
options.extend([[zl[i][i] for i in range(3)]])
options.extend([[zl[i][2-i] for i in range(3)]])
c=0
for i in options:
tmp=list(set(i))
if len(tmp)==1 and tmp[0]=='B':
print("BoBo wins!")
elif len(tmp)==1 and tmp[0]=='K':
print("KiKi wins!")
else:
c+=1
if c==8:
print("No winner!") n=3
a=[]
b=0
for i in range(0,n):
a.append(list(map(str, input().split())))
if (a[0][0]==a[0][1] and a[0][0]==a[0][2] )&nbs***bsp;(a[0][0]==a[1][1] and a[0][0]==a[2][2] )&nbs***bsp;(a[0][0]==a[1][0] and a[0][0]==a[2][0]):
b=1
elif (a[0][2]==a[1][1] and a[0][2]==a[2][0])&nbs***bsp;(a[0][2]==a[1][2] and a[0][2]==a[2][2]):
b=2
elif (a[2][0]==a[2][1] and a[2][0]==a[2][2])&nbs***bsp;(a[0][1]==a[1][1] and a[1][1]==a[2][1]):
b=3
elif (a[1][0]==a[1][1] and a[1][1]==a[1][2]):
b=4
if b==1:
if str(a[0][0])=="K":
print("KiKi wins!")
elif str(a[0][0])=="B":
print("BoBo wins!")
else:
print("No winner!")
if b==2:
if str(a[0][2])=="K":
print("KiKi wins!")
elif str(a[0][2])=="B":
print("BoBo wins!")
else:
print("No winner!")
if b==3:
if str(a[2][1])=="K":
print("KiKi wins!")
elif str(a[2][1])=="B":
print("BoBo wins!")
else:
print("No winner!")
if b==4:
if str(a[1][1])=="K":
print("KiKi wins!")
elif str(a[1][1])=="B":
print("BoBo wins!")
else:
print("No winner!")