Advertisement
RobertDeMilo

Игра бермуда

Jun 8th, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int X = 9;
  6. const int Y = 7;
  7.  
  8. int main()
  9. {
  10.     char game_space[X][Y];
  11.  
  12.     char cx, cy;
  13.  
  14.     for (int x = 0; x < X; x++)
  15.     {
  16.         for (int y = 0; y < Y; y++)
  17.         {
  18.             game_space[x][y] = '.';
  19.         }
  20.     }
  21.  
  22.     bool loop_end = false;
  23.     int xin, yin;
  24.  
  25.     do
  26.     {
  27.         cout << "  1 2 3 4 5 6 7 8 9" << endl;
  28.  
  29.         for (int y = 0; y < Y; y++)
  30.         {
  31.             cout << (char)('A' + y); // 'A' + 1 = 2  (char)('A' + 1) = 'B'
  32.  
  33.             for (int x = 0; x < X; x++)
  34.             {
  35.                 cout << " " << game_space[x][y];
  36.             }
  37.  
  38.             cout << endl;
  39.         }
  40.        
  41.         cin >> cx >> cy;
  42.         xin = cx - '1';
  43.         yin = cy - 'A';
  44.  
  45.         if (xin >= 0 && xin < 9 && yin >= 0 && yin < 7)
  46.         {
  47.             game_space[xin][yin] = 'x';
  48.         }
  49.         else
  50.         {
  51.             loop_end = true;
  52.         }
  53.  
  54.     } while (!loop_end);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement