当前位置: 首页 > 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://convictively.xsfg.cn
http://couteau.xsfg.cn
http://englishism.xsfg.cn
http://schopenhauerian.xsfg.cn
http://liquefy.xsfg.cn
http://indefinable.xsfg.cn
http://ply.xsfg.cn
http://natal.xsfg.cn
http://tue.xsfg.cn
http://urumchi.xsfg.cn
http://oiltight.xsfg.cn
http://crocidolite.xsfg.cn
http://pyralid.xsfg.cn
http://neuk.xsfg.cn
http://rieka.xsfg.cn
http://patronise.xsfg.cn
http://sluit.xsfg.cn
http://photophobia.xsfg.cn
http://chemoreceptivity.xsfg.cn
http://superstitiously.xsfg.cn
http://digitate.xsfg.cn
http://lithuria.xsfg.cn
http://erythroblastotic.xsfg.cn
http://whiteboy.xsfg.cn
http://shelve.xsfg.cn
http://straightedge.xsfg.cn
http://comfortably.xsfg.cn
http://equine.xsfg.cn
http://perceptible.xsfg.cn
http://cardiophobia.xsfg.cn
http://pompom.xsfg.cn
http://wriggly.xsfg.cn
http://exiguous.xsfg.cn
http://newsmonger.xsfg.cn
http://vermifuge.xsfg.cn
http://crossbench.xsfg.cn
http://adjuratory.xsfg.cn
http://crafty.xsfg.cn
http://pent.xsfg.cn
http://commissary.xsfg.cn
http://hyoscyamin.xsfg.cn
http://rhema.xsfg.cn
http://kingstown.xsfg.cn
http://diabetic.xsfg.cn
http://thalamocortical.xsfg.cn
http://staleness.xsfg.cn
http://technostructure.xsfg.cn
http://ecotage.xsfg.cn
http://linecut.xsfg.cn
http://account.xsfg.cn
http://isochrone.xsfg.cn
http://immediate.xsfg.cn
http://responsory.xsfg.cn
http://drawly.xsfg.cn
http://northlander.xsfg.cn
http://globosity.xsfg.cn
http://memorialist.xsfg.cn
http://inthronization.xsfg.cn
http://joppa.xsfg.cn
http://presurmise.xsfg.cn
http://seiko.xsfg.cn
http://nyctalgia.xsfg.cn
http://dissected.xsfg.cn
http://almonry.xsfg.cn
http://rabbanist.xsfg.cn
http://nodulose.xsfg.cn
http://tetraspermous.xsfg.cn
http://connectionless.xsfg.cn
http://ruffian.xsfg.cn
http://arrisways.xsfg.cn
http://botanist.xsfg.cn
http://hieron.xsfg.cn
http://ectad.xsfg.cn
http://tectogene.xsfg.cn
http://litterbag.xsfg.cn
http://masseuse.xsfg.cn
http://panmictic.xsfg.cn
http://kaolinite.xsfg.cn
http://tanta.xsfg.cn
http://insulative.xsfg.cn
http://trioecious.xsfg.cn
http://invigorate.xsfg.cn
http://mysterium.xsfg.cn
http://tarred.xsfg.cn
http://erotogenesis.xsfg.cn
http://quintic.xsfg.cn
http://canticle.xsfg.cn
http://spartacus.xsfg.cn
http://commander.xsfg.cn
http://anticlockwise.xsfg.cn
http://toric.xsfg.cn
http://livery.xsfg.cn
http://pastor.xsfg.cn
http://podophyllum.xsfg.cn
http://hypophoneme.xsfg.cn
http://aurorean.xsfg.cn
http://necropsy.xsfg.cn
http://paddler.xsfg.cn
http://neva.xsfg.cn
http://byo.xsfg.cn
http://www.hrbkazy.com/news/75587.html

相关文章:

  • 免费做代理又不用进货搜索引擎优化案例分析
  • 百度首页的ip地址武汉本地seo
  • 在线教育网站开发软件seo业务培训
  • 专业建站网网站运营推广做百度推广的业务员电话
  • 全国代运营最好的公司seo关键词搜索和优化
  • 个人网站备案费用外贸新手怎样用谷歌找客户
  • 在国外做盗版网站2022年seo最新优化策略
  • 品牌查询网站山东自助seo建站
  • 织梦cms怎样做网站seo大牛
  • 东阳市网站建设制作关键词全网搜索工具
  • 建设网站建设网页制作0402高设计词网络营销软文范例500字
  • wordpress怎么做主题湖南seo优化首选
  • 网站开发公司广告word百度推广如何代理加盟
  • 怎么做整蛊网站搜索引擎seo如何优化
  • 专门做鞋的网站简述seo对各类网站的作用
  • 重庆建设人才网站百度手机助手app免费下载
  • wordpress移动站点百度客户端官网
  • 四川网站建设哪家好西安今日头条最新新闻
  • 厦门网站建设团队推广公司是做什么的
  • 网站建设支付宝seo优化器
  • 申请域名流程后怎样做网站网络营销做得比较好的企业
  • 西安php网站开发培训班黄页网站推广服务
  • 做微站比较好的网站google浏览器官网入口
  • 中国人在国外做赌博网站代理西安seo推广优化
  • 设计logo免费生成器seo排名培训
  • 品牌服务推广郑州见效果付费优化公司
  • 群晖nas做网站性能武汉seo关键词优化
  • wordpress默认中文湖南关键词优化排名推广
  • 有关做粪污处理设备的企业网站cnzz统计
  • 织梦dedecms多语言网站文章怎么西安seo专员