cracklepop

CracklePop implementation in C for the Recurse Center
git clone git://jacobedwards.org/cracklepop
Log | Files | Refs | README

main.c (441B)


      1 #include <stdio.h>
      2 
      3 int
      4 cracklepop(unsigned int n)
      5 {
      6 	int cp;
      7 
      8 	cp = 0;
      9 	if (n % 3 == 0) {
     10 		if (printf("Crackle") < 0)
     11 			return 1;
     12 		cp = 1;
     13 	}
     14 
     15 	if (n % 5 == 0) {
     16 		if (printf("Pop") < 0)
     17 			return 1;
     18 		cp = 1;
     19 	}
     20 
     21 	if (cp) {
     22 		return printf("\n") < 0;
     23 	}
     24 
     25 	return printf("%d\n", n) < 0;
     26 }
     27 
     28 int
     29 main(void)
     30 {
     31 	unsigned int i;
     32 
     33 	for (i = 1; i <= 100; ++i) {
     34 		if (cracklepop(i)) {
     35 			perror("cracklepop");
     36 			return 1;
     37 		}
     38 	}
     39 
     40 	return 0;
     41 }