Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

fizzbuzz

Name: Anonymous 2012-03-13 7:15

#include <stdio.h>
int main(void) {
    int i = 0;
    char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
    while (i++ < 100)
        printf(s[(!(i%3))|((!(i%5))<<1)], i);
    return 0;
}


http://codepad.org/nkFXJqlG

Name: Anonymous 2012-03-13 13:45

>>9
can you test this too

#include <stdio.h>
 
#define N 100
 
int main(void) {
  char arr[] = "%d\n%d\nfizz\n%d\nbuzz\nfizz\n%d\n%d\nfizz\nbuzz\n%d\nfizz\n%d\n%d\nfizzbuzz\n";
  int news[]={0,3,6,11,14,19,24,27,30,35,40,43,48,51,54,63};
  int i=N/15, j=1;
 
  while(i--){
   printf(arr, j, j+1, j+3, j+6, j+7, j+10, j+12, j+13);
   j+=15;
  }
  arr[news[N%15]]='\0';
  printf(arr, j, j+1, j+3, j+6, j+7, j+10, j+12, j+13);
 
  return 0;  
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List