1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <array>
using namespace std;
void displaySeats(char array[]);
void displaySeats(char display[][]){
for (int row = 0; row < display[row].length; row++){
cout << " " << (row + 1) << " ";
for (int col = 0; col < display[row].length; col++)
{cout << " " << display[row][col] << " ";}
}
}
int main( )
{
char display[7][4] = { {'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'}};
string seat;
int one, two;
char r, c;
cout << "\n Enter Row (1-7) and Seat (A-D) or -1 to stop: ";
cin >> seat;
while(seat != ("-1")){
r = seat[0];
c = seat[1];
one = r - '1';
two = c - 'A';
if (display[one][two] == 'X'){
cout << " The Seat is not Available." << endl;
cout << " Please Pick another Seat." << endl;
}
else{
cout << " The Seat is Available." << endl;
display[one][two] = 'X';
}
displaySeats(display);
}
system("pause");
return 0;
}
|