题解 | #井字棋#
井字棋
https://www.nowcoder.com/practice/0375c1d206ef48a3894f72aa07b2fdde
#include<stdio.h> int main() { char arr[3][3] = { 0 }; //定义棋盘 int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { scanf(" %c", &arr[i][j]); //注意加空格,不然字母只能输6个 } } //输入 if (arr[0][0] + arr[0][1] + arr[0][2] == 'K'+'K'+'K' || arr[1][0] + arr[1][1] + arr[1][2] == 'K' + 'K' + 'K' || arr[2][0] + arr[2][1] + arr[2][2] == 'K' + 'K' + 'K' || arr[0][0] + arr[1][0] + arr[2][0] == 'K' + 'K' + 'K' || arr[0][1] + arr[1][1] + arr[2][1] == 'K' + 'K' + 'K' || arr[0][2] + arr[1][2] + arr[2][2] == 'K' + 'K' + 'K' || arr[0][0] + arr[1][1] + arr[2][2] == 'K' + 'K' + 'K' || arr[2][0] + arr[1][1] + arr[0][2] == 'K' + 'K' + 'K')printf("KiKi wins!"); else if (arr[0][0] + arr[0][1] + arr[0][2] == 'B'+'B'+'B' || arr[1][0] + arr[1][1] + arr[1][2] == 'B' + 'B' + 'B' || arr[2][0] + arr[2][1] + arr[2][2] == 'B' + 'B' + 'B' || arr[0][0] + arr[1][0] + arr[2][0] == 'B' + 'B' + 'B' || arr[0][1] + arr[1][1] + arr[2][1] == 'B' + 'B' + 'B' || arr[0][2] + arr[1][2] + arr[2][2] == 'B' + 'B' + 'B' || arr[0][0] + arr[1][1] + arr[2][2] == 'B' + 'B' + 'B' || arr[2][0] + arr[1][1] + arr[0][2] == 'B' + 'B' + 'B')printf("BoBo wins!"); else printf("No winner!"); //结果判断 return 0; } //俺是萌新