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

Another Elegence vs. Readability

Name: Anonymous 2011-05-31 3:57

/* Problem: We want [4][4], [4][5], [5][4], and [5][5] to all be four, and the rest to be generated between one and three */

/* snippet the first */
int arrays[10][10];
for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
        arrays[i][j] = /* randomly generate a number between one and three */;
    }
}
for(int i = 4; i < 6; i++){
    for(int j = 4; j < 6; j++){
        arrays[i][j] = 4;
    }
}

/* snippet the second */
int arrays[10][10];
for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
        if(/*  */){
            arrays[i][j] = 4;
        } else {
            arrays[i][j] = /* randomly generate a number between one and three */;
        }
    }
}


Which snippet would you use?
Excuse the pseudo-ish code.

Name: Anonymous 2011-06-04 16:07

The C-style comments (/* ... */) are often preferred over the C++-style comments (// ...\n) because they do not introduce ``significant whitespaces'', and they're claimed to be more elegant and readable. Now, observe:

int a = 10, b = 0, c = 30;
int *p = b;

printf("%d\n", a/*p);
printf("%d\n", /*c*/<<2);


What will this code do?

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