Created
December 9, 2012 04:56
-
-
Save willbailey/4243382 to your computer and use it in GitHub Desktop.
Twelve Days of Christmas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
char *days[] = {"first", "second", "third", "fourth", "fifth", "sixth", | |
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"}; | |
char *gifts[] = {"a partridge in a pear tree", "two turtle doves", | |
"three french hens", "four calling birds", "***** five golden rings *****", | |
"six geese a laying", "seven swans a swimming", "eight maids a milking", | |
"nine ladies dancing", "ten lords a leaping", "eleven pipers piping", | |
"twelve drummers drumming" | |
}; | |
int bird_gift_count = 0; | |
for (int i = 1; i < 13; i++) { | |
printf("\nOn the %s day of Christmas my true love gave to me,\n", days[i - 1]); | |
for (int ii = i; ii > 0; ii--) { | |
if (ii == 0 && i > 0) printf("and "); | |
printf("%s \n", gifts[ii - 1]); | |
if (ii < 8 && ii != 5) bird_gift_count += ii; | |
} | |
} | |
// better stock up on birdseed my love | |
printf("\ntotal birds received: %i\n", bird_gift_count); | |
return 0; | |
} |
It's for a Christmas Card. I was going for a retro look.
Maybe I should've done it in FORTRAN
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In C? Really!?