Suppose I have a 4*4 matrix and I prompt to enter some position and that position is 4,1
(upward movement)now I want to iterate through positions (3,1) - (2,1) - (1,1) , check those values and sometimes I must change those values and finally print a new matrix with updates values
similarly how to iterate through (4,3) , (3,3) (2,3) , (1,3) if some one enters the position as 4,4 (left movement)
I have tried , this so far ..
for(rowCount = 0; rowCount < rows; rowCount++) {
for(columnCount = 0; columnCount < columns; columnCount++){
if(rowCount == specialRow && columnCount == specialColumn)
{
if(board[rowCount][columnCount] = 1 )
{
printf("%d \t",board[rowCount][columnCount]);
board[rowCount][columnCount] = 0 ;
}
}
for(rowCount = 0; rowCount < rows; rowCount++) {
for(columnCount = 0; columnCount < columns; columnCount++)
printf("%d \t",board[rowCount][columnCount]);
printf("\n");
}
}
}
- rows means maximum rows
- columns means maximum columns
- rowCount for row iteration
- columnCount for colum iteration
- specialRow and sepcialColumn for the new position entered (from this position we have scan values in upward/left/backward directions) .
if(board[rowCount][columnCount] = 1 )
:=
-->==
? – BLUEPIXY