Java教程

翻译练习 Day9

本文主要是介绍翻译练习 Day9,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

题目:Tic-tac-toe | JXNUOJ

翻译:

Tic-tac-toe

1000ms 65536K

描述:

Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.

每个人都熟悉一字棋游戏。规则确实很简单。两名玩家轮流在3 × 3的格子中标记方格(一名玩家画叉字,另一名玩家总是画圈)。第一个在水平、垂直或对角线上画出三个对应图形的玩家获胜,游戏结束。画叉的玩家先走。如果网格被填满,但是x和o都没有出现在所需的直线上,那么就宣布平局。

You are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below:

给你一个3 × 3的网格,每个网格单元格都是空的,或者被一个叉或零所占据。你必须找到下一个轮到谁的玩家(第一名或第二名),或者输出以下结论之一:

  • illegal — if the given board layout can't appear during a valid game;
  • the first player won — if in the given board layout the first player has just won;
  • the second player won — if in the given board layout the second player has just won;
  • draw — if the given board layout has just let to a draw.
  • 非法—-如果给定的棋盘布局不能在一个有效的游戏中出现
  • 如果在给定的棋盘布局中,第一个玩家赢了
  • 如果在给定的棋盘布局中,第二个玩家赢了
  • 平局—如果给定的棋盘布局会平局。

输入:

The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero).

输入共三行,每行包含字符“。”、“X”或“0”(句点、大写字母X或数字0)。

输出:

Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.

输出六结果中的一个:第一,第二,非法,第一玩家赢,第二玩家赢或平局。

样例输入:

X0X
.0.
.X.

样例输出:

second
这篇关于翻译练习 Day9的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!