Console.WriteLine("请输入您的身份证号码");
string x = Console.ReadLine();
string year=x.Substring (6,4);//从身份证的第六位开始截取,往后截取四位,就是你的出生年份
int x1 = Convert.ToInt32(year);//把截取到年份代入到x1中,
string sx = "";
switch(x1%12)//输入一个年份取余,如果假设取余为四,你能判断那年的生肖,然后根据十二生肖排列,判断取余为0到12分别为哪个生肖
{
case 0:
sx="狗";
break;
case 1:
sx = "鸡";
break;
case 2:
sx = "猴";
break;
case 3:
sx = "羊";
break;
case 4:
sx = "马";
break;
case 5:
sx = "蛇";
break;
case 6:
sx = "龙";
break;
case 7:
sx = "兔";
break;
case 8:
sx = "虎";
break;
case 9:
sx = "牛";
break;
case 10:
sx = "鼠";
break;
case 11:
sx = "猪";
break;
default :
sx = "请输入正确的年份";
break;
}
Console.WriteLine("您的生肖是"+sx);
Console.ReadLine();