Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Confusing enough? Like it?

Name: brunch 2011-05-09 21:17

void sudoku_print(const Sudoku* sudoku){
    int i = 0;
    if (!sudoku)
        return;

    printf("+=====+=====+=====+");

    for (i = 0; i < 81; i++){
        if (!(i % 9)){
            if (i)
                printf("|");
            printf("\n");
        }
        if (!(i % 27) && i)
            printf("¦-----+-----+-----¦\n");
        if (!(i % 3))
            printf("|");
        else
            printf("¦");


        printf("%c", sudoku->puzzle[i/9][i%9]);
    }

    printf("|\n+=====+=====+=====+\n");
}

Name: Anonymous 2011-05-09 21:50

Not using [m][code][/m] tags.
Initialising [code]i[/code] twice.
Use either 1D or 2D arrays exclusively, this just looks painful.
[code]printf[/code] with no formatting applied.
Modulo everywhere.
Rewrite to remove [code]if (i)[/code] and friends: useless 80 times out of 81.
Some other stuff.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List