这是原问题:
You will be given the sequence of moves (supposing the first move is always done by
X) - by the numbers of cells where marks are placed - and your task is to determine, at which step the first line was completed (by any side).Input data contain the number of test-cases in the first line.
Next lines have one test-case each - exactly9numbers, describing cells to which moves are performed in order.
Answer should contain the number of the move at which game is won by one of players (starting from1) or0if the game is drawn (no winner) after the last move.Example:
input data: 3 7 5 4 1 9 2 8 3 6 5 1 3 7 6 4 2 9 8 5 1 2 8 6 4 7 3 9 answer: 7 6 0Test data: copy and paste them as an input for your program
11 8 4 1 3 7 6 9 5
井字棋判断输赢功能实现
最新推荐文章于 2024-09-23 21:12:38 发布
该博客介绍了一个井字棋游戏的输赢判断功能实现。通过输入玩家的移动序列,程序会判断在哪一步棋局结束并决定胜者。作者使用了两个二维数组来存储X和O的棋子位置,并提供了相应方法来检查游戏状态。即使游戏未完成,程序也能预测输赢。在给定的测试数据中,给出了具体的示例和输出结果。

最低0.47元/天 解锁文章
3923

被折叠的 条评论
为什么被折叠?



