can some tell me how to make tic tac toe program WITHOUT using array..?? and its in C.. i'm not asking for someone todo my work..just a wanted alittle help..
can some tell me how to make tic tac toe program WITHOUT using array..?? and its in C.. i'm not asking for someone todo my work..just a wanted alittle help..
Using a single 32bit integer and bit masking, you can easily* pull this off.
That should get you started.Code:#define X0 (1<< 0) #define O0 (1<<10) ... #define X8 (1<< 8) #define O8 (1<<18) long board = 0; if( board & X0 || board & O0 ) printf("The first spot on the board is filled by %c", board & X0 ? 'X' : 'O' );
[edit] Curses! Foiled again! [/edit]
Quzah.
*Your mileage may vary.
Hope is the first step on the road to disappointment.
Here's another amusing idea:
See, no array! You could even have fun with some pointers and use it as an array if you're so inclined. If you're really bored, use the 'offsetof' macro for added fun.Code:struct { char _0; char _1; char _2; char _3; char _4; char _5; char _6; char _7; char _8; } board; board._0 = 'X'
Quzah.
Hope is the first step on the road to disappointment.
You could also do it using nine int variables and a lot of if statements...yucky. Why don't you want to use an array?
Away.
Even when I was learing, instructors made no sense. I was supposed to do a CHI Square program in assembler (shudder)Originally posted by Salem
> Why don't you want to use an array?
Because its a homework exercise I guess
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers