Last change
on this file since cbc2fcf was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
1.3 KB
|
Line | |
---|
1 | /*
|
---|
2 | =============================================================================
|
---|
3 | chinayr.c -- return the Chinese Year of the ...
|
---|
4 | Version 1 -- 1988-05-19 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define TESTER /* define for a test program */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | =============================================================================
|
---|
12 | chinayr() -- returns a pointer to a static string for the Chinese year
|
---|
13 | =============================================================================
|
---|
14 | */
|
---|
15 |
|
---|
16 | char *
|
---|
17 | chinayr(year)
|
---|
18 | register int year;
|
---|
19 | {
|
---|
20 | static char *chyrs[] = { /* Chinese Year cycle */
|
---|
21 |
|
---|
22 | "Rat", /* 0 */
|
---|
23 | "Ox", /* 1 */
|
---|
24 | "Tiger", /* 2 */
|
---|
25 | "Rabbit", /* 3 */
|
---|
26 | "Dragon", /* 4 */
|
---|
27 | "Snake", /* 5 */
|
---|
28 | "Horse", /* 6 */
|
---|
29 | "Ram", /* 7 */
|
---|
30 | "Monkey", /* 8 */
|
---|
31 | "Cock", /* 9 */
|
---|
32 | "Dog", /* 10 */
|
---|
33 | "Boar" /* 11 */
|
---|
34 | };
|
---|
35 |
|
---|
36 | year -= 4;
|
---|
37 |
|
---|
38 | if (year < 0)
|
---|
39 | return("?????");
|
---|
40 | else
|
---|
41 | return(chyrs[year % 12]);
|
---|
42 | }
|
---|
43 |
|
---|
44 | /* |
---|
45 |
|
---|
46 | */
|
---|
47 |
|
---|
48 | #ifdef TESTER
|
---|
49 |
|
---|
50 | #include "stdio.h"
|
---|
51 |
|
---|
52 | extern int atoi();
|
---|
53 |
|
---|
54 | main(argc, argv)
|
---|
55 | int argc;
|
---|
56 | char *argv[];
|
---|
57 | {
|
---|
58 | register int n;
|
---|
59 |
|
---|
60 | while (--argc) {
|
---|
61 |
|
---|
62 | n = atoi(*++argv);
|
---|
63 |
|
---|
64 | if (n < 4)
|
---|
65 | printf("%4d is out of range\n", n);
|
---|
66 | else
|
---|
67 | printf("%4d is the Year of the %s\n", n, chinayr(n));
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.