c++ - Direction of for loop based on variable -
i have couple of biggish loops separate functions reduce code duplication.
the difference between them first line of loop.
one is:
for (int j = 50; j < average_diff; j++) {
the other is:
for (int j = upper_limit; j > lower_limit; j--) {
i have integer, tb indicates 1 i'd use (it has value of 1 or 2 respectively).
i'm wondering how might best accomplish this. use case macros?
don't wrap for
, wrap contents in function:
for (int j = 50; j < average_diff; j++) { process(j); } (int j = upper_limit; j > lower_limit; j--) { process(j); }
Comments
Post a Comment