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.