【C++】 C++游戏设计---五子棋小游戏

server/2024/11/14 13:12:58/
class="tags" href="/C.html" title=c>cle class="tags" href="/C.html" title=c>class="baidu_pl">
class="tags" href="/C.html" title=c>cle_class="tags" href="/C.html" title=c>content" class="tags" href="/C.html" title=c>class="articlass="tags" href="/C.html" title=c>cle_class="tags" href="/C.html" title=c>content class="tags" href="/C.html" title=c>clearfix">
class="tags" href="/C.html" title=c>content_views" class="tags" href="/C.html" title=c>class="markdown_views prism-atom-one-light">class="tags" href="/C.html" title=c>cap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-bloclass="tags" href="/C.html" title=c>ck" style="-webkit-tap-highlight-class="tags" href="/C.html" title=c>color: rgba(0, 0, 0, 0);">

1. 游戏介绍

一个简单的 C++ 五子棋小游戏

1.1 游戏规则:
  • 双人轮流输入下入点坐标
  • 横竖撇捺先成五子连线者胜
  • 同一坐标点不允许重复输入
1.2 初始化与游戏界面
  • 初始化界面
  • class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/6aa12496686441f3920class="tags" href="/C.html" title=c>ca9f87e549ab4.png" alt="在这里插入图片描述" />
  • X 输入坐标后
  • class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/2521932e75f34bclass="tags" href="/C.html" title=c>c7a008ea70f9d05aa4.png" alt="在这里插入图片描述" />
  • O 输入坐标后
  • class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/ad5class="tags" href="/C.html" title=c>c93de20ff430480845369753289d5.png" alt="在这里插入图片描述" />
  • X 先达到胜出条件

class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/class="tags" href="/C.html" title=c>cef597class="tags" href="/C.html" title=c>cb7b0b47f5b7670070680b765d.png" alt="在这里插入图片描述" />

2. 源代码

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iostream>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><veclass="tags" href="/C.html" title=c>ctor>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><algorithm>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><limits>class="tags" href="/C.html" title=c>class="token keyword">using class="tags" href="/C.html" title=c>class="token keyword">namespaclass="tags" href="/C.html" title=c>ce stdclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>const class="tags" href="/C.html" title=c>class="token keyword">int BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">15class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">initBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">" "class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">isBoardFullclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 横向检查class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">maxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, x class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= x class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">minclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, x class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 纵向检查class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">maxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, y class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= y class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">minclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, y class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 斜向(从左上到右下)检查class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">maxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[y class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[x class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">minclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[y class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[x class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 斜向(从右上到左下)检查class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">maxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">- i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">- i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[y class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[x class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator"><= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">minclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">- i class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& y class="tags" href="/C.html" title=c>class="token operator">- i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[y class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[x class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">mainclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">initBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">bool isPlayerX class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">bool gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">while class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token operator">!gameOverclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">"Player X" class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">"Player O"class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">", enter your move (row class="tags" href="/C.html" title=c>column): "class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cin class="tags" href="/C.html" title=c>class="token operator">>> y class="tags" href="/C.html" title=c>class="token operator">>> xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">|| x class="tags" href="/C.html" title=c>class="token operator">>= BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">|| y class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">|| y class="tags" href="/C.html" title=c>class="token operator">>= BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">|| boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">!= class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">"Invalid move. Try again." class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>continueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">'X' class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">'O'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">"Player X wins!" class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">"Player O wins!"class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">isBoardFullclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">"It's a draw!" class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{isPlayerX class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token operator">!isPlayerXclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>code>

3. 主要代码释解

这段代码是一个简单的五子棋游戏的实现࿰class="tags" href="/C.html" title=c>c;下面是对主要函数和异常错误处理机制的详解:

  1. <class="tags" href="/C.html" title=c>code>initBoard()class="tags" href="/C.html" title=c>code>
    • 功能:初始化棋盘࿰class="tags" href="/C.html" title=c>c;将所有位置设置为’.'࿰class="tags" href="/C.html" title=c>c;表示空白。
    • 实现:通过双重循环遍历二维数组<class="tags" href="/C.html" title=c>code>boardclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;并将每个元素设置为’.'。
  2. <class="tags" href="/C.html" title=c>code>printBoard()class="tags" href="/C.html" title=c>code>
    • 功能:打印当前棋盘的状态。
    • 实现:通过双重循环遍历二维数组<class="tags" href="/C.html" title=c>code>boardclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;并打印每个元素。
  3. <class="tags" href="/C.html" title=c>code>isBoardFull()class="tags" href="/C.html" title=c>code>
    • 功能:检查棋盘是否已满。
    • 实现:通过双重循环遍历二维数组<class="tags" href="/C.html" title=c>code>boardclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;如果所有位置都不是’.'࿰class="tags" href="/C.html" title=c>c;则返回<class="tags" href="/C.html" title=c>code>trueclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;表示棋盘已满。
  4. <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWin(int x, int y, class="tags" href="/C.html" title=c>char player)class="tags" href="/C.html" title=c>code>
    • 功能:检查给定玩家是否在(x, y)位置获胜。
    • 实现:检查横向、纵向、两个对角线方向是否有连续的 5 个相同的棋子。如果找到࿰class="tags" href="/C.html" title=c>c;则返回<class="tags" href="/C.html" title=c>code>trueclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;表示该玩家获胜。
  5. <class="tags" href="/C.html" title=c>code>main()class="tags" href="/C.html" title=c>code>
    • 功能:游戏的主循环࿰class="tags" href="/C.html" title=c>c;处理玩家的输入࿰class="tags" href="/C.html" title=c>c;更新棋盘状态࿰class="tags" href="/C.html" title=c>c;并判断游戏是否结束。
    • 实现
      • 初始化棋盘。
      • 在一个循环中交替让两个玩家输入他们的移动。
      • 检查移动是否有效(即在棋盘范围内且位置为空)。
      • 更新棋盘࿰class="tags" href="/C.html" title=c>c;并检查是否有玩家获胜或棋盘已满。

4. 异常和错误处理机制

  1. 输入有效性检查
    • 在<class="tags" href="/C.html" title=c>code>main()class="tags" href="/C.html" title=c>code>函数中࿰class="tags" href="/C.html" title=c>c;玩家输入移动后࿰class="tags" href="/C.html" title=c>c;代码检查移动是否在棋盘范围内࿰class="tags" href="/C.html" title=c>c;以及对应位置是否为空。
    • 如果移动无效(即<class="tags" href="/C.html" title=c>code>xclass="tags" href="/C.html" title=c>code>或<class="tags" href="/C.html" title=c>code>yclass="tags" href="/C.html" title=c>code>超出范围࿰class="tags" href="/C.html" title=c>c;或者对应位置不是’.')࿰class="tags" href="/C.html" title=c>c;则打印错误消息࿰class="tags" href="/C.html" title=c>c;并通过<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>continueclass="tags" href="/C.html" title=c>code>跳过当前循环的剩余部分࿰class="tags" href="/C.html" title=c>c;提示玩家重新输入。
  2. 棋盘满时结束游戏
    • 在玩家每次移动后࿰class="tags" href="/C.html" title=c>c;调用<class="tags" href="/C.html" title=c>code>isBoardFull()class="tags" href="/C.html" title=c>code>检查棋盘是否已满。
    • 如果棋盘已满࿰class="tags" href="/C.html" title=c>c;则打印平局消息࿰class="tags" href="/C.html" title=c>c;并通过设置<class="tags" href="/C.html" title=c>code>gameOverclass="tags" href="/C.html" title=c>code>为<class="tags" href="/C.html" title=c>code>trueclass="tags" href="/C.html" title=c>code>结束游戏。
  3. 检查获胜条件
    • 在玩家每次移动后࿰class="tags" href="/C.html" title=c>c;调用<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWin()class="tags" href="/C.html" title=c>code>检查该玩家是否获胜。
    • 如果玩家获胜࿰class="tags" href="/C.html" title=c>c;则打印获胜消息࿰class="tags" href="/C.html" title=c>c;并通过设置<class="tags" href="/C.html" title=c>code>gameOverclass="tags" href="/C.html" title=c>code>为<class="tags" href="/C.html" title=c>code>trueclass="tags" href="/C.html" title=c>code>结束游戏。

5. 可改进点

  • 异常处理:代码中没有使用 C++ 的异常处理机制࿰class="tags" href="/C.html" title=c>c;例如<class="tags" href="/C.html" title=c>code>try-class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>chclass="tags" href="/C.html" title=c>code>块。在某些情况下࿰class="tags" href="/C.html" title=c>c;如果输入不是整数࿰class="tags" href="/C.html" title=c>c;<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code>会进入错误状态࿰class="tags" href="/C.html" title=c>c;这可能导致无限循环。可以通过检查<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code>的状态并清除错误标志来处理这种情况。
  • 边界条件检查:在<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWin()class="tags" href="/C.html" title=c>code>函数中࿰class="tags" href="/C.html" title=c>c;对斜向检查的边界条件处理可以进一步优化࿰class="tags" href="/C.html" title=c>c;以避免不必要的条件判断。
  • 代码重用:<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWin()class="tags" href="/C.html" title=c>code>函数中的横向、纵向和斜向检查有大量重复代码࿰class="tags" href="/C.html" title=c>c;可以通过提取重复代码到单独的函数中来简化。

这个游戏实现简单࿰class="tags" href="/C.html" title=c>c;但包含了基本的游戏逻辑和错误处理机制࿰class="tags" href="/C.html" title=c>c;适合作为学习<class="tags" href="/C.html" title=c>code>C++class="tags" href="/C.html" title=c>code>和游戏编程的入门项目。



6. 追更

  • 6.1 优化了判胜代码
<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查给定玩家是否在(x, y)位置沿一个方向获胜
class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int dxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int dyclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">= x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">* dxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">= y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">* dyclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckYclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckXclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查给定玩家是否在(x, y)位置获胜
class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查水平方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查垂直方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查两个斜线方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>code>
6.2 完整代码
  • class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>ch_254">优化了判胜代码并增加了<class="tags" href="/C.html" title=c>code>try-class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>chclass="tags" href="/C.html" title=c>code>块捕获异常࿰class="tags" href="/C.html" title=c>c;仅供参考
<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iostream>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><veclass="tags" href="/C.html" title=c>ctor>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><limits>class="tags" href="/C.html" title=c>class="token keyword">using class="tags" href="/C.html" title=c>class="token keyword">namespaclass="tags" href="/C.html" title=c>ce stdclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>const class="tags" href="/C.html" title=c>class="token keyword">int BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">15class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 初始化棋盘
class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">initBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 打印棋盘
class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">" "class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查棋盘是否已满
class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">isBoardFullclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZEclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查给定玩家是否在(x, y)位置沿一个方向获胜
class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int dxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int dyclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token operator">++iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">= x class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">* dxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">= y class="tags" href="/C.html" title=c>class="token operator">+ i class="tags" href="/C.html" title=c>class="token operator">* dyclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckX class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">>= class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckY class="tags" href="/C.html" title=c>class="token operator">< BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">&& boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckYclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckXclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">== playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>countclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">breakclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>count class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查给定玩家是否在(x, y)位置获胜
class="tags" href="/C.html" title=c>class="token keyword">bool class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查水平方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查垂直方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 检查两个斜线方向class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">|| class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckDireclass="tags" href="/C.html" title=c>ctionclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token operator">-class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, playerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">mainclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">initBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">bool isPlayerX class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">bool gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">falseclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">while class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token operator">!gameOverclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">int xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">"Player X" class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">"Player O"class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">", enter your move (row class="tags" href="/C.html" title=c>column): "class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">try class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cin class="tags" href="/C.html" title=c>class="token operator">>> y class="tags" href="/C.html" title=c>class="token operator">>> xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">.class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">failclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">.class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>clearclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 清除错误标志class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">.class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">ignoreclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>class-name">numericlass="tags" href="/C.html" title=c>c_limitsclass="tags" href="/C.html" title=c>class="token operator"><streamsizeclass="tags" href="/C.html" title=c>class="token operator">>class="tags" href="/C.html" title=c>class="token operator">::class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">maxclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token string">'\n'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 忽略错误输入class="tags" href="/C.html" title=c>class="token keyword">throw class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">runtime_errorclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token string">"Invalid input. Please enter numbers."class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(x class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">|| x class="tags" href="/C.html" title=c>class="token operator">>= BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">|| y class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token number">0 class="tags" href="/C.html" title=c>class="token operator">|| y class="tags" href="/C.html" title=c>class="token operator">>= BOARD_SIZE class="tags" href="/C.html" title=c>class="token operator">|| boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">!= class="tags" href="/C.html" title=c>class="token string">'.'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">throw class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">runtime_errorclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token string">"Invalid move. Try again."class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">'X' class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">'O'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">class="tags" href="/C.html" title=c>checlass="tags" href="/C.html" title=c>ckWinclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, boardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[yclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[xclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(isPlayerX class="tags" href="/C.html" title=c>class="token operator">? class="tags" href="/C.html" title=c>class="token string">"Player X wins!" class="tags" href="/C.html" title=c>class="token operator">: class="tags" href="/C.html" title=c>class="token string">"Player O wins!"class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">isBoardFullclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">printBoardclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token string">"It's a draw!" class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;gameOver class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token boolean">trueclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">else class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{isPlayerX class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token operator">!isPlayerXclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">} class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>ch class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>const runtime_errorclass="tags" href="/C.html" title=c>class="token operator">& eclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< eclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">.class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">whatclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 可以选择在这里处理错误࿰class="tags" href="/C.html" title=c>c;例如跳过当前玩家的回合class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 或者让玩家重新输入࿰class="tags" href="/C.html" title=c>c;取决于你的游戏规则class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>code>

在这个修改后的代码中࿰class="tags" href="/C.html" title=c>c;<class="tags" href="/C.html" title=c>code>try-class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>chclass="tags" href="/C.html" title=c>code>块被用来捕获两种异常情况:

  1. 当<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code>接收到非数字输入时࿰class="tags" href="/C.html" title=c>c;会进入错误状态。<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cin.fail()class="tags" href="/C.html" title=c>code>检查输入流是否失败࿰class="tags" href="/C.html" title=c>c;如果是࿰class="tags" href="/C.html" title=c>c;则清除错误标志࿰class="tags" href="/C.html" title=c>c;并忽略错误输入直到下一个换行符。然后抛出一个<class="tags" href="/C.html" title=c>code>runtime_errorclass="tags" href="/C.html" title=c>code>异常。
  2. 当用户输入的坐标无效时(即不在棋盘范围内或该位置已被占用)࿰class="tags" href="/C.html" title=c>c;也会抛出一个<class="tags" href="/C.html" title=c>code>runtime_errorclass="tags" href="/C.html" title=c>code>异常。
    在<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>catclass="tags" href="/C.html" title=c>chclass="tags" href="/C.html" title=c>code>块中࿰class="tags" href="/C.html" title=c>c;我们捕获了<class="tags" href="/C.html" title=c>code>runtime_errorclass="tags" href="/C.html" title=c>code>异常࿰class="tags" href="/C.html" title=c>c;并打印出异常信息。根据你的游戏规则࿰class="tags" href="/C.html" title=c>c;你可以选择让当前玩家重新输入࿰class="tags" href="/C.html" title=c>c;或者跳过当前玩家的回合࿰class="tags" href="/C.html" title=c>c;或者采取其他适当的错误处理措施。

在这个例子中࿰class="tags" href="/C.html" title=c>c;我们只是打印了错误信息࿰class="tags" href="/C.html" title=c>c;然后循环会继续࿰class="tags" href="/C.html" title=c>c;提示玩家重新输入。


http://www.ppmy.cn/server/141597.html

相关文章

「Mac玩转仓颉内测版3」入门篇3 - Cangjie的基本语法与结构

本篇将深入探讨Cangjie语言的基本语法与结构。这些基础知识为编写高效、可维护的代码奠定了坚实基础。通过理解语句结构、表达式、注释及数据类型&#xff0c;能够更自信地使用Cangjie进行编程。 关键词 Cangjie基本语法语句结构表达式注释数据类型控制结构 一、基本语法 1.…

设计模式-七个基本原则之一-单一职责原则 + SpringBoot案例

单一职责原理:(SRP) 面向对象七个基本原则之一 清晰的职责&#xff1a;每个类应该有一个明确的职责&#xff0c;避免将多个责任混合在一起。降低耦合&#xff1a;通过将不同的职责分开&#xff0c;可以降低类之间的耦合度&#xff0c;提高系统的灵活性。易于维护&#xff1a;当…

Node.js笔记

问&#xff1a;npm install时&#xff0c;报错误&#xff1a;Failed to remove some directories。怎么办&#xff1f; 答&#xff1a;我在使用npm安装electron时总是报上面的错误&#xff0c;具体如下&#xff0c;我问遍了KIMI和通义&#xff0c;回答的方法都解决不了。还搜索…

组件间通信(组件间传递数据)

组件间通信(组件间传递数据) 在 Vue.js 中&#xff0c;组件间通信是开发者需要经常处理的任务&#xff0c;特别是在构建具有多层次组件的复杂应用时。根据组件之间的关系和数据流的复杂程度&#xff0c;可以采用不同的通信方式。以下是常用的几种组件间通信方式&#xff1a; …

在uniapp中封装请求接口 (带刷新token)

import { apiUrl } from /config/global-config.js import { useUserStore } from ../stores import { usePageRoute } from "/composable/usePageRoute.js"// 默认配置 const DEFAULT_CONFIG {timeout: 60000,// showLoading: true,// loadingText: 加载中... }// …

Kubernetes的基本构建块和最小可调度单元pod-0

文章目录 一&#xff0c;什么是pod1.1pod在k8s中使用方法&#xff08;1&#xff09;使用方法一&#xff08;2&#xff09;使用方法二 1.2pod中容器的进程1.3pod的网络隔离管理&#xff08;1&#xff09;pause容器的作用 1.4 Pod分类&#xff1a;&#xff08;1&#xff09;自主式…

C语言第九周课——经典算法

目录 一、冒泡法排序 1.1原理 1.2代码实现&#xff08;以升序排序为例&#xff09; 1.3逻辑 1.4分析 二、二分法查找 2.1原理 2.2代码实现 2.3逻辑 2.4算法效率分析 三、素数判断 3.1原理 3.2代码实现 3.3逻辑 3.4分析 一、冒泡法排序 1.1原理 冒泡排序&…

数据仓库还是数据集市?这俩怎么选?

数据仓库和数据集市作为支持决策分析的两种不同方式&#xff0c;根据各自的特点和优势&#xff0c;有不同的应用场景&#xff0c;今天就来探讨下数据集市和数据仓库该怎么选&#xff1f; 一、数据集市和数据仓库对比 1、数据集市与数据仓库的关系&#xff1a; 1&#xff09;数…