Java根据年份算出所属的生肖。

一个小程序~

 

	public String getYear(Integer year){
		if(year<1900){
			return "未知";
		}
		Integer start=1900;
		String [] years=new String[]{
				"鼠","牛","虎","兔",
				"龙","蛇","马","羊",
				"猴","鸡","狗","猪"
				};
		return years[(year-start)%years.length];
	}


 

 

posted on 2013-09-25 20:45  you Richer  阅读(607)  评论(0编辑  收藏  举报