Hi, how do I make a 2-dimensional square array of single letters and make it output in a matrix-like fashion? This is what I have so far, but I can't find a way to input the letters into the array:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <iomanip>
int main()
{
int boardSize = 3;
char board[boardSize][boardSize] = {'a','d','z'}, {'p','A','I'}, {'Q','G','v'};
std::cout << std::setw(1);
for (int i=0;i<=boardSize-1;i++)
{
for (int j=0;j<=boardSize-1;j++)
{
std::cout << board[i][j] << " ";
}
}
}
I also need all letters to be separated by a space and take up exactly the same amount of space. Am I doing it right? For example, the program above (if it worked) should output something like this:
1 2 3
a d z
p A I
Q G v
Please have a look at my code and point out my mistakes. Thanks!