#include <stdio.h> void CSH(char qipan[3][3]) //接收棋盘 { for(int i = 0;i<3;++i) for(int j = 0;j<3;++j) scanf("%c ",&qipan[i][j]); } char Winer(char qipan[3][3]) //判断棋盘获胜者 { for(int i = 0;i<3;++i) { if(qipan[0][i]==qipan[1][i]&& qipan[1][i]==qipan[2][i] &&qipan[1][i]!='O') //行相同 return qipan[0][i]; if(qipan[i][0]==qipan[i][1]&& qipan[i][1]==qipan[i][2] &&qipan[i][1]!='O') //列相同 return qipan[i][0]; } if(qipan[0][0]==qipan[1][1] && qipan[1][1]==qipan[2][2] && qipan[1][1]!='O') //对角线相同 return qipan[1][1]; if(qipan[0][2]==qipan[1][1] && qipan[1][1]==qipan[2][0] && qipan[1][1]!='O') return qipan[1][1]; return 'O'; //都不相同 } int main() { char qipan[3][3]={0}; CSH(qipan); char x = Winer(qipan); //接收 if(x == 'K') printf("KiKi wins!\n"); else if(x == 'B') printf("BoBo wins!\n"); else printf("No winner!\n"); return 0; }