Apr 10, 2010 at 2:01am UTC
This is what I came up with but it just crashes when I run it.
Any ideas! Please help!
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
#include <iostream>
using namespace std;
int main()
{
bool seats[15][30];
int loop;
int row = 1;
int col = 1;
do
{
do
{
seats[row][col] = true ;
row++;
}
while (row < 15);
col++;
} while (col < 30);
system ("Pause" );
}
Last edited on Apr 10, 2010 at 2:03am UTC
Apr 10, 2010 at 2:10am UTC
It should start at 0, not one. Arrays go from 0 to size-1, not 1 to size.
Apr 10, 2010 at 2:11am UTC
start row/col at zero, not at 1. Remember that arrays are zero based.. ie the first element is [0].
use a for loop instead of a do/while loop. This can be accomplished with a do/while, but it's a little weird.
Your problem is due to 'row' not being reset to zero in the outer loop. This problem will disappear with a properly written for loop.
Apr 10, 2010 at 2:15am UTC
Can you please show me I tried using a for loop first but I couldn't figure it out.
Cause I have to make 450 different values to true. and every time the row goes to 15 column has to go up by 1.