_056_根据年份判断十二生肖

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
//在控制台应用程序中调用MessageBox函数需要在资源管理中引用system.windows.forms;
using System.Windows.Forms; namespace _056_根据年份判断十二生肖 { class Program { static void Main(string[] args) { System.Globalization.ChineseLunisolarCalendar chineseCaleander =new System.Globalization.ChineseLunisolarCalendar(); string TreeYear = "鸡狗猪鼠牛虎兔龙蛇马羊猴"; //string TreeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
       //此处两种方法,一种方法是采用chineseCaleander类进行计算,另一种直接除以12取余,如果余数为1则为鸡年,依次类推;
//int intYear = chineseCaleander.GetSexagenaryYear(DateTime.Now); int intYear = DateTime.Now.Year % 12; string Tree = TreeYear.Substring(chineseCaleander.GetTerrestrialBranch(intYear) - 1, 1); Console.WriteLine("今年是十二生肖" + Tree + ""); MessageBox.Show("今年是十二生肖" + Tree + "", "判断十二生肖", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }

猜你喜欢

转载自www.cnblogs.com/yuanshou/p/10660524.html