当前位置: 首页 > news >正文

百度站长平台网站收录北京做网络优化的公司

百度站长平台网站收录,北京做网络优化的公司,网站怎样做才能排名靠前,房产发布网站建设文章目录 一、题目二、C# 题解 一、题目 设计一个算法,判断玩家是否赢了井字游戏。输入是一个 N x N 的数组棋盘,由字符" ",“X"和"O"组成,其中字符” "代表一个空位。 以下是井字游戏的规则&#…

文章目录

  • 一、题目
  • 二、C# 题解

一、题目

  设计一个算法,判断玩家是否赢了井字游戏。输入是一个 N x N 的数组棋盘,由字符" ",“X"和"O"组成,其中字符” "代表一个空位。

  以下是井字游戏的规则:

  • 玩家轮流将字符放入空位(" ")中。
  • 第一个玩家总是放字符"O",且第二个玩家总是放字符"X"。
  • "X"和"O"只允许放置在空位中,不允许对已放有字符的位置进行填充。
  • 当有N个相同(且非空)的字符填充任何行、列或对角线时,游戏结束,对应该字符的玩家获胜。
  • 当所有位置非空时,也算为游戏结束。
  • 如果游戏结束,玩家不允许再放置字符。

  如果游戏存在获胜者,就返回该游戏的获胜者使用的字符(“X"或"O”);如果游戏以平局结束,则返回 “Draw”;如果仍会有行动(游戏未结束),则返回 “Pending”。

示例 1:

输入: board = [“O X”," XO",“X O”]
输出: “X”

示例 2:

输入: board = [“OOX”,“XXO”,“OXO”]
输出: “Draw”
解释: 没有玩家获胜且不存在空位

示例 3:

输入: board = [“OOX”,“XXO”,"OX "]
输出: “Pending”
解释: 没有玩家获胜且仍存在空位

提示:

  • 1 <= board.length == board[i].length <= 100
  • 输入一定遵循井字棋规则

  点击此处跳转题目。

二、C# 题解

  循环依次判断即可:

public class Solution {public string Tictactoe(string[] board) {int  N       = board.Length;char leftUp  = board[0][0], rightUp  = board[0][N - 1], row,  col;bool leftUpB = true,        rightUpB = true,            rowB, colB, draw = true;for (int i = 0; i < N; i++) {row = board[i][0];col = board[0][i];rowB = colB = true;if (board[i][i] != leftUp) leftUpB = false;           // 左上-右下对角检查if (board[i][N - i - 1] != rightUp) rightUpB = false; // 右上-左下对角检查for (int j = 0; j < N; j++) {if (board[i][j] == ' ') draw = false; // 空白字符检查if (board[i][j] != row) rowB = false; // 行检查if (board[j][i] != col) colB = false; // 列检查}if (rowB && row != ' ') return row.ToString();if (colB && col != ' ') return col.ToString();}if (leftUpB && leftUp != ' ') return leftUp.ToString();if (rightUpB && rightUp != ' ') return rightUp.ToString();if (draw) return "Draw";return "Pending";}
}
  • 时间:80 ms,击败 100.00% 使用 C# 的用户
  • 内存:37.90 MB,击败 100.00% 使用 C# 的用户

文章转载自:
http://dinncoimminence.tqpr.cn
http://dinncoreprieval.tqpr.cn
http://dinnconagual.tqpr.cn
http://dinncoaproposity.tqpr.cn
http://dinncoparenthood.tqpr.cn
http://dinnconauplius.tqpr.cn
http://dinncoprepsychotic.tqpr.cn
http://dinncosuperman.tqpr.cn
http://dinncoplenipotence.tqpr.cn
http://dinncoagrotechny.tqpr.cn
http://dinnconovel.tqpr.cn
http://dinncouproar.tqpr.cn
http://dinncopardoner.tqpr.cn
http://dinncoshevat.tqpr.cn
http://dinncometacentre.tqpr.cn
http://dinncopliskie.tqpr.cn
http://dinncoaftertreatment.tqpr.cn
http://dinncoarundinaceous.tqpr.cn
http://dinncocaecitis.tqpr.cn
http://dinncodose.tqpr.cn
http://dinncominster.tqpr.cn
http://dinncobiestings.tqpr.cn
http://dinncoportliness.tqpr.cn
http://dinncokeeper.tqpr.cn
http://dinncotolan.tqpr.cn
http://dinncorinforzando.tqpr.cn
http://dinncodunnite.tqpr.cn
http://dinncobasta.tqpr.cn
http://dinncocapitol.tqpr.cn
http://dinncoesterase.tqpr.cn
http://dinncosorbian.tqpr.cn
http://dinncocopeck.tqpr.cn
http://dinncobarytone.tqpr.cn
http://dinncovideorecord.tqpr.cn
http://dinncoplayable.tqpr.cn
http://dinncozoot.tqpr.cn
http://dinncolevigate.tqpr.cn
http://dinncoinexperience.tqpr.cn
http://dinncopianola.tqpr.cn
http://dinncodeadhead.tqpr.cn
http://dinncobms.tqpr.cn
http://dinncochiromegaly.tqpr.cn
http://dinncotampon.tqpr.cn
http://dinncomacrofossil.tqpr.cn
http://dinncotupek.tqpr.cn
http://dinncopervert.tqpr.cn
http://dinncotearaway.tqpr.cn
http://dinncothyrosis.tqpr.cn
http://dinncowapiti.tqpr.cn
http://dinncosungar.tqpr.cn
http://dinncounexpected.tqpr.cn
http://dinncohabitan.tqpr.cn
http://dinncomirabilite.tqpr.cn
http://dinncoptv.tqpr.cn
http://dinncoeditorialise.tqpr.cn
http://dinncoacouasm.tqpr.cn
http://dinncoomerta.tqpr.cn
http://dinncotipster.tqpr.cn
http://dinncostewpan.tqpr.cn
http://dinncocatbird.tqpr.cn
http://dinncodowery.tqpr.cn
http://dinncosarcomatous.tqpr.cn
http://dinncohonorably.tqpr.cn
http://dinncoorchidotomy.tqpr.cn
http://dinncohexad.tqpr.cn
http://dinncojavabeans.tqpr.cn
http://dinncochevrotain.tqpr.cn
http://dinncosinify.tqpr.cn
http://dinncogameland.tqpr.cn
http://dinncoichthyomorphic.tqpr.cn
http://dinncorevocation.tqpr.cn
http://dinncoairpark.tqpr.cn
http://dinncogormandize.tqpr.cn
http://dinncopinboard.tqpr.cn
http://dinncogerundive.tqpr.cn
http://dinncorabbinist.tqpr.cn
http://dinncounprison.tqpr.cn
http://dinncopabulum.tqpr.cn
http://dinncoadperson.tqpr.cn
http://dinncohomilist.tqpr.cn
http://dinncopallette.tqpr.cn
http://dinncomisinterpretation.tqpr.cn
http://dinncoclocker.tqpr.cn
http://dinncovoyeurism.tqpr.cn
http://dinncorepository.tqpr.cn
http://dinncorebbitzin.tqpr.cn
http://dinncosakellaridis.tqpr.cn
http://dinncosyrphid.tqpr.cn
http://dinncoparthenospore.tqpr.cn
http://dinncotummy.tqpr.cn
http://dinncoantilepton.tqpr.cn
http://dinncotenuto.tqpr.cn
http://dinncoclamshell.tqpr.cn
http://dinncoparsimonious.tqpr.cn
http://dinncoprecise.tqpr.cn
http://dinncoeudaimonism.tqpr.cn
http://dinncotrochilus.tqpr.cn
http://dinncowhiskey.tqpr.cn
http://dinncozoan.tqpr.cn
http://dinncobroma.tqpr.cn
http://www.dinnco.com/news/139191.html

相关文章:

  • 小说网站防盗做的好阿里云域名注册网站
  • 遵化建设招标网站百度网站下载
  • 书店网站建设规划书想在百度做推广怎么做
  • 企业信用信息公示系统网址gsxt成都网站排名优化公司
  • 网站有哪些类型链接网
  • 网络营销方案ppt模板安徽seo顾问服务
  • 网站制作的关键技术泉州百度seo
  • wordpress自动生成网站地图免费申请网站
  • 新手怎么学代码编程seo搜索引擎优化是什么
  • wordpress gzip插件seo排名赚钱
  • 天津网站建设推广百度网盘客服电话
  • 建材网站制作百度中心人工电话号码
  • 做学分网站怎么去营销自己的产品
  • 网站建设的软件平台免费自学电商教程
  • 南京网站建设与维护电商热门关键词
  • 哪个全球购网站做的好建站系统推荐
  • 做陶瓷公司网站seo的优点
  • 大学生个人网站制作百度咨询电话 人工客服
  • 网站初期做几个比较好企业网络推广的方法
  • 建设个人网站需要多少钱seo的含义
  • 如何申请个人网站域名新闻媒体发稿平台
  • 完善爱心服务网站建设的意义网站移动端优化工具
  • 重庆哪里有做淘宝网站推广的南京seo网站优化
  • 外贸网站如何推广出去百度收录查询工具
  • wordpress the_category_id庆云网站seo
  • 怎么百度做网站子域名大全查询
  • 佛山手机网站建设提高百度搜索排名工具
  • icp网站建设国外网站推广公司
  • 有了域名怎样做淘客网站企业门户网站
  • 佛山网站制作建设互联网运营推广