Puzzle hrlp

Pages: 12
Put each whole line of the grid in without pressing enter after each element. Look where the line feeds '\n' are in the stringstream.
I'm so so sorry
The input should have space between
Example
1 0 0 1
1 0 1 0
1 1 1 0
0 0 1 0

Is there any way to solve the space problem
Last edited on
@Dee,
If you insist on using spaces between elements then you can use a 2-d int array or vector of vectors instead of the char array implied by using strings. That is the only change.

It would take very little for you to transform grid[] in the code above to such an array. So I think you could do that yourself.

BTW. Make sure that your latest 4x4 example is feasible. It has no route between top left and bottom right.
Where exactly should I do the changes
Also please add comments in the code so as I can understand it better
I learn through other codes and through books I don't study c++ in school
C'mon @lastchance Get with the program and hurry up. Dee5's got a deadline to meet.
@Dee5, if you change
1
2
   vector<string> grid(N);
   for ( int i = 0; i < N; i++ ) in >> grid[i];

to
1
2
3
   vector<string> grid(N,string(N,' '));
   for ( int i = 0; i < N; i++ )
      for ( int j = 0; j < N; j++ ) in >> grid[i][j];

then it will work regardless of whether the input has spaces or not.

This is my last contribution to this thread.
Topic archived. No new replies allowed.
Pages: 12