#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string seatPlan [5][5];
string cols ;
string rows;
cout<<"A "<<"B "<<"C "<<"D "<<"E "<<endl;
for (int i=0;i<5;i++){
for (int j=0;j<5;j++){
cout<<seatPlan[i][j];
cout<<' * ';
}
cout<<endl;
}
cout<<"Please enter seat row and column you wish to reserve: \n";
cout<<endl;
for (int i=0;i<5;i++){
cin>>rows;
cin>>cols;
seatPlan[rows][cols];//--- there is problem here ??!!
}
}
here i want to make the user chose the seat as A5 or A6
but i dont know how to do it?? what datatype i should use ??!!
and how i make the seat like this ((THE NUMBER OF ROWS))
- A B C D E
1 * * * * *
2 * * * * *
3 * * * * *
4 * * * * *
5 * * * * *
Your problem is in line 25. You are trying to call an array while using strings as the indicies. This won't work. To call an array element you need to put integers (or ints) in the square brackets.
OKAY I CHOOSE THE FIRST ONE ...
BUT how can i put (*) instead of 0 in seat plan AND WHEN I CHOOSE A SEAT IT CHANGED TO "R".
- A B C D E
10 0 0 0 0
20 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
5 0 0 0 0 0
THIS IS THE CODE