home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / SNPD9404.ZIP / MOON_AGE.C < prev    next >
Text File  |  1994-04-03  |  638b  |  21 lines

  1. .I 3 2
  2. **  Returns 0 for new moon, 15 for full moon,
  3. **  29 for the day before new, and so forth.
  4. .D 4 2
  5. .I 16 3
  6.              28, 9, 20, 1, 12, 23, 4, 15, 26, 7};
  7.       static short int offsets[] =
  8.             {-1, 1, 0, 1, 2, 3, 4, 5, 7, 7, 9, 9};
  9. .D 17 3
  10. .I 22 2
  11.       return ((ages[(year + 1) % 19] + ((day + offsets[month-1]) % 30) +
  12.             (year < 1900)) % 30);
  13. .D 23 35
  14. .I 75 3
  15. static char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
  16.                          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  17.  
  18. .I 91 1
  19.       printf("Moon phase on %d %s %d is %s\n", day, months[month - 1], year,
  20. .D 92 1
  21.