This is the problem
Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows:
A 1 2 3 4 5
B 1 2 3 4 5
C 1 2 3 4 5
D 1 2 3 4 5
E 1 2 3 4 5
The program should display the seat pattern with an 'X' marking the seats already assigned. For example, after seats 1A, 2B and 4C are taken, the display should look like this:
A X 2 3 4 5
B 1 X 3 4 5
C 1 2 3 X 5
D 1 2 3 4 5
E 1 2 3 4 5
After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that the seat is occupied and ask for another choice.
Except you have to use a dynamic array and the program is supposed to ask the user how many rows the plane has and then handles that many rows.
I can't figure out how to show the seats at the end...
#include<iostream>
using namespace std;
int main()
{
char ans, column;
int rows;
char seats[7][4];
do {
cout << "Enter the number of rows the plane has: " << endl;
cin >> rows;
char *p[4];
cout << "Enter the seat number you wish to sit in (A to D): " << endl;
cin >> column;
for (int i=0; i<4; i++)
p[i] = new char[rows];
for (int i=0; i<rows; i++)
{ for (int j=0; j<4; j++)
{ cout << p[j][i] << " ";
}
cout << endl;
}
//Display seats
cout << "Do you want to add another seat? (Y or N)" << endl;
cin >> ans;
}while(ans == 'Y' || ans == 'y');
return 0;
}