0

Help!! Placing obstacles on a maze.

Hi, so I have a 2D int array providing me some positions let's say {3,4}{0,1} and I have a 2D char array which is full of dots '.' All I wanna do is place an obstacle '#' in the char array at positions given in the int array. It should be really easy but couldn't figure out please help me.

27th Feb 2020, 6:46 AM
Arafatur Rahman
Arafatur Rahman - avatar
2 odpowiedzi
+ 2
Show us what you tried... If not started, then take a loop, with if, where row, colomn is set in int array, assign # in char array on same row, colomn index...
27th Feb 2020, 7:24 AM
Jayakrishna 🇮🇳
+ 1
char[][] maze = new char[5][5]; int [][] obstacles = {{1,1},{2,2},{3,3}}; for (int[] p: obstacles) { maze [p[0]] [p[1]] = '#'; }
27th Feb 2020, 10:09 AM
zemiak