Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int X = 9;
- const int Y = 7;
- int main()
- {
- char game_space[X][Y];
- char cx, cy;
- for (int x = 0; x < X; x++)
- {
- for (int y = 0; y < Y; y++)
- {
- game_space[x][y] = '.';
- }
- }
- bool loop_end = false;
- int xin, yin;
- do
- {
- cout << " 1 2 3 4 5 6 7 8 9" << endl;
- for (int y = 0; y < Y; y++)
- {
- cout << (char)('A' + y); // 'A' + 1 = 2 (char)('A' + 1) = 'B'
- for (int x = 0; x < X; x++)
- {
- cout << " " << game_space[x][y];
- }
- cout << endl;
- }
- cin >> cx >> cy;
- xin = cx - '1';
- yin = cy - 'A';
- if (xin >= 0 && xin < 9 && yin >= 0 && yin < 7)
- {
- game_space[xin][yin] = 'x';
- }
- else
- {
- loop_end = true;
- }
- } while (!loop_end);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement