如何输出一个井字游戏表
How do I output a tic tac toe table?
这是我到目前为止的函数,但它没有产生正确的输出。任何帮助吗?
void Display(char gameBoard[][SIZE])
{
int row, col;
for (row = 0; row < SIZE; row++)
{
cout << "-----------" << endl;
for (col = 0; col < SIZE; col++)
{
cout << gameBoard[row][col] << " |";
}
}
}
我猜这就是你真正想要的代码:
void Display(char gameBoard[][SIZE])
{
int row, col;
for (row = 0; row < SIZE; row++)
{
cout << "----------" << endl;
cout << "|";
for (col = 0; col < SIZE; col++)
{
cout << gameBoard[row][col] << " |";
}
cout << endl;
}
cout << "----------" << endl;
}
cout << "/n/t" << " | " << "/n/t" << " | " << "/t";
cout << "/n/t" << "----------------";
这可能有效。
希望这对你有帮助!这将是一个整洁的板!
#include <iostream>
#include <string>
using namespace std;
int main() {
int SIZE = 3;
int row, col;
string gameBoard[3][3];
//Initializing what gameBoard is -- I made it equal to 'X'
for (row = 0; row < SIZE; row++)
{
for (col = 0; col < SIZE; col++)
{
gameBoard[row][col] = 'X';
}
}
//Outputing the table
for (row = 0; row < SIZE; row++)
{
for (col = 0; col < SIZE; col++)
{
if (col == 0) {
cout << gameBoard[row][col] << " ";
}
else {
cout << " | " << gameBoard[row][col];
}
}
if (row != SIZE - 1) {
cout << endl << "--------------------" << endl;
}
}
cout << "n";
return 0;
}
如果你有任何问题就问!
相关文章:
- 有没有办法让我编写一个可以在Windows和Linux上运行的命令行游戏?
- 我正在尝试创建一个 C++ 贪吃蛇游戏,但我似乎无法绘制第二个高度边框,我该如何解决这个问题?
- 将四元数旋转的游戏对象旋转另一个四元数时出现问题
- 我在视觉工作室中制作了一个类似胭脂的游戏,我想显示玩家的生命值
- OpenGL 2D游戏只绘制第二个精灵纹理而不是第一个
- 一个创建彩票游戏的程序,该彩票游戏可以有效地创建 10 套而没有任何重复?
- 致命错误LNK1169:在C++Visual Studio中编写战舰游戏时发现的一个或多个多重定义的符号
- 我正在制作一个刽子手游戏,我需要帮助弄清楚为什么它不能完全工作
- 要读取一个从一个游戏应用程序(In C )到我的Android应用程序的文件
- 在C 中创建一个猜测游戏
- 在此过程中的纸牌游戏程序.不知道为什么我会得到一个随机数-858993460
- UE4 -C :如何设计一个本地Coop游戏,其中字符具有不同的输入方案
- 使用C 组合精灵的不同部分在iOS游戏中形成一个单个精灵
- 切换始终在猜测一个数字游戏上输出默认值
- 如何使用.txt文件从我的数独游戏C的另一个文件中获得输入
- 如何在c++骰子游戏中存储第一个值,并在下一步进行比较
- 如何创建一个简单的侧滚动游戏
- 为wp7构建了一个将在wp8和w8上运行的游戏
- 我不能在不使用指针的情况下返回 2d 数组!我正在制作一个井字游戏类型游戏,这是我的向上移动功能
- 我正在设计一个程序,可以计算如果您玩了几个刮刮乐彩票游戏,获利的几率