Skip to content

Commit

Permalink
fizzbuzz58.c: Use addition, not indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-S-Thompson committed Oct 20, 2017
1 parent 5b028c2 commit f3ac10e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions fizzbuzz58.c
Expand Up @@ -5,21 +5,21 @@ int main(void) {
const char *format;
struct format *next;
} formats[] = {
[1] = { "Fizz\n", &formats[6] },
[d] = { "Fizz\n", &formats[3] },
[8] = { "%d\n", &formats[c] },
[2] = { "%d\n", &formats[d] },
[7] = { "%d\n", &formats[2] },
[b] = { "%d\n", &formats[1] },
[9] = { "FizzBuzz\n", &formats[7] },
[e] = { "%d\n", &formats[9] },
[a] = { "Buzz\n", &formats[b] },
[4] = { "Fizz\n", &formats[a] },
[5] = { "Buzz\n", &formats[0] },
[0] = { "Fizz\n", &formats[8] },
[3] = { "%d\n", &formats[5] },
[6] = { "%d\n", &formats[e] },
[c] = { "%d\n", &formats[4] },
[1] = { "Fizz\n", formats+6 },
[d] = { "Fizz\n", formats+3 },
[8] = { "%d\n", formats+c },
[2] = { "%d\n", formats+d },
[7] = { "%d\n", formats+2 },
[b] = { "%d\n", formats+1 },
[9] = { "FizzBuzz\n", formats+7 },
[e] = { "%d\n", formats+9 },
[a] = { "Buzz\n", formats+b },
[4] = { "Fizz\n", formats+a },
[5] = { "Buzz\n", formats+0 },
[0] = { "Fizz\n", formats+8 },
[3] = { "%d\n", formats+5 },
[6] = { "%d\n", formats+e },
[c] = { "%d\n", formats+4 },
};
struct format *format = formats+7;
for (int i = 1; i <= 100; i ++) {
Expand Down

0 comments on commit f3ac10e

Please sign in to comment.