Selling seats in a theater program for school.

Ok so for school I have to sell tickets for a theater and I will ask the user what seat they want to buy, they will tell me what ROW and what COLUMN they wish to sit in, so for example in a 10 by 20 theater they would say they want to sit in row 5 column 17.

When they tell me this I need to set the 5 x 17 seat as sold.

My question is how am I suppose to write the code to turn their input into a sold seat??

I have : bool seats[10][20];

Please choose your row:

Please choose your column:


What am I suppose to have them cin? cin >> seats[10][0]; ? and cin >> seats[0][20]; ?


And once they do that how do I set the coordinate 5 x 17 to false (sold) ?

Please help I am really confused.
Last edited on
You're getting the indices of your matrix from the user. It works the same way as a normal array except with more subscripts.
1
2
3
cin >> row;
cin >> col;
array[row][col] = false;
I would recommend you have some error checking, in case the user enters a row or column that does not exist, otherwise you may wind up crashing (accessing memory outside of the arrays).
Topic archived. No new replies allowed.