求编12生肖程序
急!!!!求助!!!!!!用VC编辑器
求程序::::
输入任意一个12生肖属性;输出它相对应的12时辰;
12生肖属性: 鼠,牛,虎,兔,龙,蛇,马,羊,猴,鸡,狗,猪;
相对应的12时辰: 子,丑,寅,卯,辰,巳,午,未,申,酉,戌,亥;
程序代码:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *time = "子丑寅卯辰巳午未申酉戌亥",
*animal = "鼠牛虎兔龙蛇马羊猴鸡狗猪", str[3];
while (scanf("%2s", str) == 1)
{
char *dst = strstr(animal, str);
if (dst != NULL)
printf("%.2s\n", &time[dst - animal]);
}
return 0;
}