Chinese zodiac: Difference between revisions

Content added Content deleted
m (RPL typo)
(Added XPL0 example.)
Line 4,615: Line 4,615:
2020 庚子 gēng-zĭ Metal Rat Yang 37/60
2020 庚子 gēng-zĭ Metal Rat Yang 37/60
</pre>
</pre>

=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">include xpllib; \for Print

int Animals, Elements;

func GetElement(Year);
int Year, Element;
[Element:= rem((Year-4)/10) / 2;
return Elements(Element);
];

func GetAnimal(Year);
int Year;
return Animals(rem((Year-4)/12));

func GetYY(Year);
int Year;
if rem(Year/2) = 0 then return "yang"
else return "yin";

int Year, Years, I;
[Years:= [ 1935, 1938, 1968, 1972, 1976, 2017 ];
Animals:= [ "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" ];
Elements:= [ "Wood","Fire","Earth","Metal","Water" ];
for I:= 0 to 6-1 do
[Year:= Years(I);
Print("%d is the year of the %s %s (%s).\n", Year, GetElement(Year), GetAnimal(Year), GetYY(Year));
]
]</syntaxhighlight>
{{out}}
<pre>
1935 is the year of the Wood Pig (yin).
1938 is the year of the Earth Tiger (yang).
1968 is the year of the Earth Monkey (yang).
1972 is the year of the Water Rat (yang).
1976 is the year of the Fire Dragon (yang).
2017 is the year of the Fire Rooster (yin).
</pre>

=={{header|Yabasic}}==
=={{header|Yabasic}}==
<syntaxhighlight lang="yabasic">
<syntaxhighlight lang="yabasic">