gpt4 book ai didi

c# - 检查 TicTacToe 中的赢家?

转载 作者:太空狗 更新时间:2023-10-29 22:11:39 24 4
gpt4 key购买 nike

查看(在 2 人游戏中)谁赢了 Tic Tac Toe 游戏的最佳方式是什么?现在我正在使用类似于以下内容的内容:

if (btnOne.Text == "X" && btnTwo.Text == "X" && btnThree.Text == "X")
{
MessageBox.Show("X has won!", "X won!");
return;
}
else
// I'm not going to write the rest but it's really just a bunch
// if statements.

那么如何摆脱多重 if 呢?

最佳答案

一些东西:

rowSum == 3 || columnSum == 3 || diagnolSum == 3

..?

关于c# - 检查 TicTacToe 中的赢家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/740467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com