home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / rrcount < prev    next >
Internet Message Format  |  1989-02-03  |  2KB

  1. Path: xanth!mcnc!gatech!mandrill!hal!ncoast!allbery
  2. From: heckbert.pa@xerox.com
  3. Newsgroups: comp.sources.misc
  4. Subject: v03i058: Reagan Countdown Program!
  5. Message-ID: <880622-180110-2769@Xerox>
  6. Date: 23 Jun 88 01:01:06 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: heckbert.pa@xerox.com
  9. Lines: 75
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. comp.sources.misc: Volume 3, Issue 58
  13. Submitted-By: "A. Nonymous" <heckbert.pa@xerox.com>
  14. Archive-Name: rrcount
  15.  
  16. [I love it!!!  Shar'ed and modified so V7ers can use rand() and S5ers can use
  17. lrand48.  (Dumbshar.)  ++bsa]
  18.  
  19. Here is a handy program to tell you how many days Reagan has left in office.
  20. Run it from your .login.
  21. It brightens my day to see this number decreasing every time I log in!
  22. (It will also help you plan for the big party we must have when Reagan's term
  23. is over).
  24.  
  25. echo x - rrcount.c
  26. sed 's/^X//' << \EOF > rrcount.c
  27. X/*
  28. X * rrcount.c: Reagan Countdown program
  29. X * Paul Heckbert, ph@degas.berkeley.edu        9 Mar 1988
  30. X */
  31. X
  32. X#define BSD                /* use BSD rng */
  33. X/*#define USG                /* use USG rng; otherwise V7 */
  34. X
  35. X#define SEC_PER_DAY (24*3600)
  36. X#define REAGAN_TIMEOUT 601329600    /* inauguration day
  37. X                    noon, 20 Jan 1989: time to rejoice! */
  38. X
  39. Xstatic char *gipname[] = {
  40. X    "President Reagan",
  41. X    "Ronald Wilson Reagan",
  42. X    "the Insane Anglo War-Lord",    /* anagram for "Ronald Wilson Reagan" */
  43. X    "Ronnie-boy",
  44. X    "Ronnie Ray-gun",
  45. X    "the gipper",
  46. X    "the geezer",
  47. X    "Bedtime for Bonzo",
  48. X    "\"The Great Communicator\"",
  49. X    "the jelly bean king",
  50. X    "mr. 3x5 card",
  51. X};
  52. X#define GIPNUM (sizeof gipname/sizeof gipname[0])
  53. X
  54. Xdouble frandom();
  55. X
  56. Xmain()
  57. X{
  58. X    long t;
  59. X    int i;
  60. X
  61. X    t = time(0);
  62. X    srandom(t);
  63. X    for (i=0; i<30; i++) random();
  64. X    t = REAGAN_TIMEOUT-t;
  65. X    printf("%d more days of %s\n", t/SEC_PER_DAY,
  66. X    gipname[(int)(GIPNUM*frandom())]);
  67. X}
  68. X
  69. Xdouble frandom()        /* random number between 0 and 1 */
  70. X{
  71. X#ifdef BSD
  72. X    return random()/2147483647.;
  73. X#endif
  74. X#ifdef SYSV
  75. X    extern double drand48();
  76. X
  77. X    srand48(time(0) + getpid());
  78. X    return drand48();
  79. X#endif
  80. X#if !(defined(BSD) || defined(SYSV))
  81. X    srand((unsigned) time((long *) 0) + getpid());
  82. X    return rand() / ((double) (2 << 15) - 1);
  83. X#endif
  84. X}
  85. EOF
  86. exit 0
  87.