Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int row;
  7.     char column;
  8.     char answer;
  9.     char arr[8][5];
  10.     int i;
  11.     int k;
  12.     for(i = 1; i < 8; i++)
  13.     {
  14.         arr[i][1] = 'A';
  15.         arr[i][2] = 'B';
  16.         arr[i][3] = 'C';
  17.         arr[i][4] = 'D';
  18.     }
  19.  
  20.     for(i = 1; i < 8; i++)
  21.     {
  22.         cout << i << " ";
  23.         for(k = 1; k< 5; k++)
  24.         {
  25.             cout << arr[i][k] << " ";
  26.         }
  27.         cout << endl;
  28.     }
  29.     do
  30.     {
  31.  
  32.         cin >> row;
  33.         if(row < 1 || row > 7)
  34.         {
  35.             cout << endl << "Error, please select the correct row" << endl << endl;;
  36.         }
  37.         cin >> column;
  38.         switch(column)
  39.         {
  40.             case 'A':
  41.             case 'a':
  42.                 static_cast<int>(column);
  43.                 column = 1;
  44.                 break;
  45.             case 'B':
  46.             case 'b':
  47.                 static_cast<int>(column);
  48.                 column = 2;
  49.                 break;
  50.             case 'C':
  51.             case 'c':
  52.                 static_cast<int>(column);
  53.                 column = 3;
  54.                 break;
  55.             case 'D':
  56.             case 'd':
  57.                 static_cast<int>(column);
  58.                 column = 4;
  59.                 break;
  60.         }
  61.  
  62.  
  63.         if(arr[row][column] == 'x')
  64.         {
  65.             cout << "Error, seat already taken" << endl;
  66.         }
  67.         else
  68.         {
  69.             arr[row][column] = 'x';
  70.         }
  71.  
  72.         for(i = 1; i < 8; i++)
  73.         {
  74.             cout << i << " ";
  75.             for(k = 1; k< 5; k++)
  76.             {
  77.                 cout << arr[i][k] << " ";
  78.             }
  79.             cout << endl;
  80.         }
  81.         cout << "Repeat? Y/N" << endl;
  82.         cin >> answer;
  83.     }while(answer == 'Y' || answer == 'y');
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement