Welcome to the forum!
Line 7: Nice job commenting your code! This is so important and so few people do it.
Lines 7 & 9: while you may like going from 1 to n+1, I urge you to get used to going from 0 to n. That's the way that arrays are indexed so if you do it differently, you have to make all of your arrays 1 item larger than needed. It also prevents you from using range-based for loops (a sort of "for each item" construct).
Line 13:
while (3)
? why 3? It would be better to say
while(true)
Your goal is to make the code as clear as possible. In either case though, you've created an infinite loop so the program will never get out.
Line 18: Here is your problem. You're mistaking how boolean logic works. Suppose y is 'X':
-
y!='X'
is false, because y IS 'X'
-
y!='O'
is
true because y isn't 'O'
- false || true is true, by definition
What you really want is
y!='X' && y!='O'
Also sorry for any spelling or grammar mistakes |
They are both fine.
im exhausted because of trying to solve this problem myslef. |
I think the best piece of advice I can give a new programmer is this: if you get stuck for more than 30 minutes, seek out help. The answer is almost always something very simple and your time is better spent doing something fun while you wait for an answer.