Hi, I'd like to ask for help. I neeed to print maze made of '.' and '#' where '#' is wall and '.' is just place I can move at.
Maze has to be generated with exact rows and columns depending on the users input, but I've already done that with one-dimensional array (but I'm still not sure if it woud work or I will have to do that with two-dimensional array).
Start is at the upper left-hand corner and the end is at the lower right-hand corner.
Variable k has to be at the interval I've written (lowk and highk)
I need to find and write algorithm that will successfully lead you from start to finish at the exact moves (variable k)=> path will be printed from '.' and that will write '#' (walls) so that number of moves is equal to variable k.
This number of moves cannot exceed or be lower than k.
I'd use a 2D array for sure. Let the compiler do the arithmetic for you.
Line 25: n is undefined so this doesn't compile. When posting code and results, please be sure that the code generates the results.
Lines 26-31:
The first time through the loop, r==0, so line 28 sets array[0]='.'. Line 29 is true so line 30 also sets array[0]='.'.
The second time through the loop, r==1. Line 28 sets array[1]='.'. Line 29 compares array[1] to array[0] and since they're both '.', it's true and line 30 sets array[1]='.' again.
The pattern repeats. For each value of r, line 28 sets array[r]='.' and the comparison at line 29 is true.
You desired output contains '#' characters, but I don't see anything in the code that would put '#' in any location.
there's supposed to be variable columns instead of n, im sorry for that.
I know that this code will print only '.' but that's just because I dont know how write the algorithm that will print number of '#' correctly so that shortest way made of '.' will match the value of variable k. Im trying to figure it out how could it work.