Hi,
my program is kinda seating arrangement system,
it works like when i enter a seat number, the program will change the value of that array from 0 to 1. Depending on the seat number if i enter 2 it should fill only 2 cell. (and its working like that.)
1 2 3 4
Row 1 1 1 0 0 0 0 0
Row 2 0 0 0 0 0 0 0
.
.
what i want is if the cells of this array already have 1 value stored then the program should skip those cells and fill the cells those have 0 value,
for E.g:
if enter 2 it is showing
1 2 3 4
Row 1 1 1 0 0 0 0 0
Row 2 0 0 0 0 0 0 0
.
.
and if program ask again to enter seats.. and user press 3, so it should skip those cells in which value if 1 and fill other 3 cells those have 0 values.
output should be like this:
You can accomplish this by modifying the for loop on line 13 for(int j=0; j<7 && b>0; j++)
What this is saying is two conditions must be true for the for loop to continue.
Also inside the if statement where you set air[i][j] = 1; add b--;
The break statement on line 20 looks like an error to me.