Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDunge

Posted 31 August 2012 - 04:06 PM

Your code is okay.

First of all, this is mostly basic C, not C++. You don't have any classes and use global variable. Learning object-oriented development would be the next logical step in your training. You do use std (cin and cout) but that's about it. Try using containers like list, map and vectors.
Your tictactoe source use a whole lot of "if" lines. I didn't analyse it, but I'm pretty sure it could be resumed to a clearer algorithm taking much less lines of code using mathematics and logic instead of handling every possible possibilities individually.
Also, I know it was not a need in these games, but you only used variables of type int. Always try to select the best type who use the less memory for the data you handle. Instead of validating maximum using a made-up value (99999999), try using constant that means something like INT_MAX available in <limits.h>

Also, what do you mean by "move on"? You always improve while programming, it never stop. If you mean learn new things, only you can answer that. Do you understand the code you wrote? If so, go ahead because it can only help learning new ways of thinking and doing that same thing in a more efficient manner.

#1Dunge

Posted 31 August 2012 - 03:51 PM

Your code is okay.

First of all, this is mostly basic C, not C++. You don't have any classes and use global variable. Learning object-oriented development would be the next logical step in your training. You do use std (cin and cout) but that's about it. Try using containers like list, map and vectors.
Your tictactoe source use a whole lot of "if" lines. I didn't analyse it, but I'm pretty sure it could be resumed to a clearer algorithm taking much less lines of code using mathematics and logic instead of handling every possible possibilities individually.
Also, I know it was not a need in these games, but you only used variables of type int. Always try to select the best type who use the less memory for the data you handle. Instead of validating maximum using a made-up value (99999999), try using constant that means something like INT_MAX available in <limits.h>

PARTNERS