Skip to content

Instantly share code, notes, and snippets.

@Cloudef
Last active May 26, 2016 19:49
Show Gist options
  • Save Cloudef/e699b641a3c5358b16bead75ad37591c to your computer and use it in GitHub Desktop.
Save Cloudef/e699b641a3c5358b16bead75ad37591c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
void main(void)
{
char num[4];
const char *lut[] = { num, "Fizz\n", "Buff\n", "FizzBuff\n" };
for (uint32_t i = 1; i <= 100; ++i) {
const uint8_t n = !(i % 3) + (2 * !(i % 5));
snprintf(num, sizeof(num), "%d\n", i);
printf("%s", lut[n]);
}
}
#include <stdio.h>
#include <stdint.h>
void main(void)
{
const char *lut[] = { "", "Fizz\n", "Buff\n", "FizzBuff\n" };
for (uint32_t i = 1; i <= 100; ++i) {
const uint8_t n = !(i % 3) + (2 * !(i % 5));
printf("%s", lut[n]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment