Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int row;
- char column;
- char answer;
- char arr[8][5];
- int i;
- int k;
- for(i = 1; i < 8; i++)
- {
- arr[i][1] = 'A';
- arr[i][2] = 'B';
- arr[i][3] = 'C';
- arr[i][4] = 'D';
- }
- for(i = 1; i < 8; i++)
- {
- cout << i << " ";
- for(k = 1; k< 5; k++)
- {
- cout << arr[i][k] << " ";
- }
- cout << endl;
- }
- do
- {
- cin >> row;
- if(row < 1 || row > 7)
- {
- cout << endl << "Error, please select the correct row" << endl << endl;;
- }
- cin >> column;
- switch(column)
- {
- case 'A':
- case 'a':
- static_cast<int>(column);
- column = 1;
- break;
- case 'B':
- case 'b':
- static_cast<int>(column);
- column = 2;
- break;
- case 'C':
- case 'c':
- static_cast<int>(column);
- column = 3;
- break;
- case 'D':
- case 'd':
- static_cast<int>(column);
- column = 4;
- break;
- }
- if(arr[row][column] == 'x')
- {
- cout << "Error, seat already taken" << endl;
- }
- else
- {
- arr[row][column] = 'x';
- }
- for(i = 1; i < 8; i++)
- {
- cout << i << " ";
- for(k = 1; k< 5; k++)
- {
- cout << arr[i][k] << " ";
- }
- cout << endl;
- }
- cout << "Repeat? Y/N" << endl;
- cin >> answer;
- }while(answer == 'Y' || answer == 'y');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement