I just got finished with my first program (that is, the first one I haven't just copied out of a book). It's a text based version of Noughts and Crosses (aka Tic-tac-toe) without an AI, and it looks pretty ugly to me. Commenting is half-assed, some variables are given nondescript names, and I can tell that my loop structure can use a little work. Still, it runs.
Show me up, /prog/. Write a more elegant version in the language of your choice. Surely it's not a difficult task for [o][u]EXPERT PROGRAMMERS[/o][/u] such as yourselves. If you've got any suggestions for me, those would be nice, too.
x = o = 0;
if (board[0][0] == 'X') ++x;
if (board[0][0] == 'O') ++o;
if (board[1][1] == 'X') ++x;
if (board[1][1] == 'O') ++o;
if (board[2][2] == 'X') ++x;
if (board[2][2] == 'O') ++o;
if (x == 3) return x_win = 1;
if (o == 3) return o_win = 1;
x = o = 0;
if (board[0][2] == 'X') ++x;
if (board[0][2] == 'O') ++o;
if (board[1][1] == 'X') ++x;
if (board[1][1] == 'O') ++o;
if (board[2][0] == 'X') ++x;
if (board[2][0] == 'O') ++o;
if (x == 3) return x_win = 1;
if (o == 3) return o_win = 1;