#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
const int Rows = 5;
const int Cols = 5;
这是声明枚举和使用它们的正确方法吗?
enum Minesweeper { Mine = '@', Blank = '*', Loss = 'X'};
void StudentInfo ( );
void Information ( );
void make_board (Minesweeper Board [][Cols], int Rows, int mines);
int main ( )
{
StudentInfo ( );
Minesweeper Board [Rows][Cols];
int mines = 0;
cout << " Enter amount of mines (5 - 10): ";
cin >> mines;
Information ( );
make_board (Board, Rows, mines);
return 0;
}
如何将此函数设置为初始化字符而不是输出整数?
void make_board (Minesweeper Board [][Cols], int Rows, int mines)
{
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
Board [i][j] = Blank; // outputs the integer 42
cout << Board [i][j] << ' ';
}
cout << endl;
}
return;
}
这是我目前获得的输出
42 42 42 42 42
42 42 42 42 42
42 42 42 42 42
42 42 42 42 42
42 42 42 42 42
非常感谢任何帮助。谢谢
答案 0 :(得分:1)
试试这个:
cout << static_cast<char>(Board [i][j]) << ' ';