Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- //Word count
- #define WORD_C 3
- //Word definitions
- #define WORD_S {"Fizz","Buzz","Bizz"}
- //Words will be added only to odd numbers in sequence
- #define WORD_F i*2+3
- int main() {
- char words[WORD_C][20] = WORD_S;
- int wordc[WORD_C];
- size_t str_size = 0;
- for (int i=0;i < WORD_C;i++) {
- int f = WORD_F;
- wordc[i] = f;
- str_size += strlen(words[i]);
- }
- ++str_size;
- char str[str_size];
- for (int i=1;i < 100;i++) {
- strcpy(str,"\0");
- for (int j=0;j < WORD_C;j++) {
- if (i%wordc[j] == 0) {
- strcat(str,words[j]);
- }
- }
- if (strcmp(str,"\0") == 0) {
- printf("%d\n",i);
- continue;
- }
- puts(str);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement