Question #278069

Burning Bridges

by CodeChum Admin

After getting out of the strange dimension, you feel like you have to cover up your path and close the exit so that nothing strange can follow you back.


Instructions

  1. Change the value of of the element located in the array index indicated by the int variables “exitCol” and “exitRow” to ‘0’.
  2. Print out the 2D array with each element per row separated by a space and each column separated by a line.


Input

Two ints separated by a space

0·0

Output

5x5 array with each sub array in a new line and each element separated by a space

0·1·1·1·1
1·1·1·1·1
1·1·1·1·1
1·1·1·1·1
1·1·1·1·1


-----------fill up the code---------------

#include<stdio.h>


int main() {

    int exitRow,exitCol;

    scanf("%d %d", &exitRow,&exitCol);

    int row_col[5][5] = {{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1}};

    


    return 0;

}


Expert's answer

#include <stdio.h>

int main() 
{
  int exitRow, exitCol;
  scanf("%d %d", &exitRow, &exitCol);
  int row_col[5][5] = {
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 }
    { 1, 1, 1, 1, 1 }
  }
  if (exitRow < 5 && exitCol < 5) {
    row_col[exitRow][exitCol] = 0;
  }
  for (int i = 0; i < 5; i = i + 1) {
    for (int j = 0; j < 5; j = j + 1) {
      printf("%d ", row_col[i][j]);
    } printf("\n");
  }
  return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS