-
Yeah, but why 1? why minus 1 and not minus 3234342? (lol)
and why does it ask if ej/ei is bigger or smaller than 0 or 2?
and more one thing:
Code:
int board[3][3], *p = (int*)board;
int i, j, c, x, ei, ej;
//initialization
for(i = 0, c = 8; i < 3; i++)
for(j = 0; j < 3; j++, c--)
board[i][j] = c;
board[ei = 2][ej = 2] = 0;
what does these lines do?
-
not to sound like a jerk, but do you even know what a for loop is?
-
...
To repeat something a couple times (you define how many times it repeats)
:O
Well,
I will express my question differently:
What are these lines for? why do I need them for my code?
and what do they do? i know that all the "[3][3] boards now equals to c what what is c and what does it equal to? and why board[ei = 2][ej = 2] = 0? wtf? and what does ei and ej equals to?
and why *p = (int*)board? it means that *p stores the address of board? how come? usually when we wanna store data we do p = &variable_name; why is it different here?
-
>What are these lines for? why do I need them for my code?
to initialize the array.
>and what do they do? i know that all the "[3][3] boards now eqauls to c what what is c?
c is an iterator. a counter number variable thing.
> and why board[ei = 2][ej = 2] = 0? wtf?
sets the starting pos.
> and why *p = (int*)board? it means that *p stores the address of board? how come?
because the author wanted to check for a win in an inane way.
-
thanks but,
1.alright, ok.
2. what is an iteratior i don't understand.
3. starting pos? what's a pos?
4. to check a victory in an inane way? what?
and btw
why does the board[ei = 2][ej = 2] equals to 0?
and what are the ei and ej?
-
for (i=0;i<5;i++)
i is an iterator.
pos = position.
the author decided to iterate through the array as a one dimensional array instead of a two dimensional array.
-
lets try this:
what are you trying to do, not with this code, but ultimately what are you trying to accomplish by understanding what this piece of code does?
its not making sense to me as to why you're even inquiring about it when clearly you havent even attempted to learn the fundamentals.
>why do i need them for my code
what code and why are you writing code with this if you have to ask what it is that every line does?
again, not to be a jerk or anything im just confused as to why you're asking about it.
if we knew more about where you want to get to we'd be able to help you out more.
-
>Yeah, but why 1? why minus 1 and not minus 3234342? (lol)
because you can only move only space at a time.
>and why does it ask if ej/ei is bigger or smaller than 0 or 2?
it's range checking. for the array.
this:
Code:
board[ei = 2][ej = 2] = 0;
does the same thing as this:
Code:
ei = 2;
ej = 2;
board[2][2] = 0;
-
why does board[2][2] equals to 0?