Skip to content

Commit

Permalink
fizzbuzz90.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-S-Thompson committed Apr 4, 2017
1 parent 7c143ed commit 53b10f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -92,7 +92,7 @@ then unconditionally print a new-line character).

And there are a number of other ways to solve the problem.

This project contains, so far, 89 different C implementations of
This project contains, so far, 90 different C implementations of
FizzBuzz, most of them deliberately silly, using various combinations
of the `?:` conditional operator, short-circuit `&&` and `||`, function
pointers, arrays of function pointers, arrays of arrays of function
Expand Down Expand Up @@ -284,4 +284,6 @@ Please do not use these programs as examples of good programming style.
* [fizzbuzz88.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz88.c)
Compute the correct character for each position.
* [fizzbuzz89.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz89.c)
LIke fizzbuzz88.c, but without the confusing nested loop.
Like fizzbuzz88.c, but without the confusing nested loop.
* [fizzbuzz90.c](https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz90.c)
Use an array of integers.
18 changes: 18 additions & 0 deletions fizzbuzz90.c
@@ -0,0 +1,18 @@
#include <stdio.h>
int main(void) {
const int lines[] = {
1, 2, 3, 4, 5, 3, 7, 8, 3, 5, 11, 3, 13, 14, 15,
16, 17, 3, 19, 5, 3, 22, 23, 3, 5, 26, 3, 28, 29, 15,
31, 32, 3, 34, 5, 3, 37, 38, 3, 5, 41, 3, 43, 44, 15,
46, 47, 3, 49, 5, 3, 52, 53, 3, 5, 56, 3, 58, 59, 15,
61, 62, 3, 64, 5, 3, 67, 68, 3, 5, 71, 3, 73, 74, 15,
76, 77, 3, 79, 5, 3, 82, 83, 3, 5, 86, 3, 88, 89, 15,
91, 92, 3, 94, 5, 3, 97, 98, 3, 5
};
for (int i = 0; i < 100; i ++) {
lines[i] == 3 && puts("Fizz") ||
lines[i] == 5 && puts("Buzz") ||
lines[i] == 15 && puts("FizzBuzz") ||
printf("%d\n", lines[i]);
}
}

0 comments on commit 53b10f2

Please sign in to comment.