String and integer reading

So we have to design a game board that looks like this: this is an example of the game board of size 4:
ABCDE
0+ + +
1
2+ + +
3
4+ + +
When asked for user input for example (d2) or (i3) to print a '-' or '|' between pluses or in the spaces..
I need to create a function that reads the input and place it in the right place depending on the letter and number... How can I 'separate' letter from the number? and then print the char? Thanks a lot in advance.

[code]
[
#include <iostream>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <cstdlib>

using namespace std;
string make_move(string letters, int user_input)
{

}
void print_game_baord(char array[12], int user_input)
{
char letters[26] = {' ','A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'};
cout << " ";
for (int i = 0; i <= ((user_input * 2)+1); i++)
{
cout << letters[i];
}
cout << endl;
}



void make_game_baord(char array[12], int user_input)
{
for (int i = 0; i <((user_input * 2)+1); i++)
{
if (i < 10)
{
cout << " " << i;
}
else if (i >= 10)
{
cout << i;
}

for (int j = 0; j <= user_input; j++)
{
int x = i % 2;
if ( x == 0)
{
cout << "+" << " ";
}

}
cout << endl;
}
}
int main()
{
cout << "Please enter the game baord size (1 to 12): ";
int user_input;
cin >> user_input;
char board_game [12];
print_game_baord(board_game, user_input);
make_game_baord(board_game, user_input);
return 0;
]
Last edited on
Topic archived. No new replies allowed.