Re: Urgent Variable Question
Supposing x1 is a string value between "a1" and "i9", I guess instead of
Code:
cin>>*p[x1[0]+x1[1]];
you should try
Code:
cin >> *p[ (x1[0]-'a') * 9 + (x1[1]-'1') ];
But I think you should consider a methot based on 9x9 array, already suggested before by Krishnaa.
Somethink like this
Code:
int array[9][9];
cin >> array[x1[0]-'a'][x1[1]-'1'];
or even better.
Re: Urgent Variable Question
I doubt you want that. A matrix would be a better idea. Even a 2-d array would be.
For a sudoku solver you'd probably want a method to run through:
1. elements of a row.
2. elements of a column
3. elements of a box.
the first two can be done easily with a matrix, 2-d array or even valarray.
3rd one may require a bit of programming.
Re: Urgent Variable Question
lol yes i know.. the array of int x[9][9] would cover the whole thing "without" a problem, but the problems will pop out when i get to the logical part of sudoku solving (my first attempt of a sudoku solving program was obviously using an [9][9] array).
anyway, the
Code:
cin >> *p[ (x1[0]-'a') * 9 + (x1[1]-'1') ];
really did the job perfectly- THANKS!!!
however, i really want to learn about it, so can u plz explain to me way does this work?
and another thing- if i have a string x, and i insert "a1" to it, the x[0] would be the number and the x[1] would be the char (in this order), or the other way around?
THANKS FOR THE HELP AND THE SPEED !
Re: Urgent Variable Question
could someone plz explain it to me why does it work now, so i can do it on me own for the next times?
thanks..
Re: Urgent Variable Question
Can you post your project so that we can see what you've tried?
Also, what doesn't work?
Have you tried debugging the program to determine where the failure
occurs?
All you say is that it doesn't work. Where? What? How?
Re: Urgent Variable Question
actually i was kinda focus on the problem.. and the fact is that one of u guys helped me alot and solved me problem..
i just didn't understand how he did it lol..