26 for (i = 0; i <= 19; i++) {
27 j = (responses[i] - 65);
28 if(responses[i] == answers[i]) {
29 numcorrect++;
30 counter[i][j]++;
31 }
32 else
33 counter[i][j]++;
34 }
35
should have been this:
for (i = 0; i <= 19; i++) {
j = (responses[i] - 65);
counter[i][j]++;
if(responses[i] == answers[i])
numcorrect++;
}
---------------------------------------------------------------------------------------------------------------------------------
27 j = (responses[i] - 65);
28 if(responses[i] == answers[i]) {
29 numcorrect++;
30 counter[i][j]++;
31 }
32 else
33 counter[i][j]++;
34 }
35
should have been this:
for (i = 0; i <= 19; i++) {
j = (responses[i] - 65);
counter[i][j]++;
if(responses[i] == answers[i])
numcorrect++;
}
---------------------------------------------------------------------------------------------------------------------------------
They do the same thing, if something is in both loops, it doesn't need to be in either (i.e. it should be outside the loop). I should have exercised DRY.
.pc
No comments:
Post a Comment