using System;namespace ConsoleApp2{ class Program { public static readonly string[] _celestialStem = { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" }; public static readonly string[] _terrestrialBranch = { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" }; public static readonly string[] _chineseZodiac = { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" }; static void Main(string[] args) { Console.Write("请输入要计算天干地支和生肖的年份: "); string str = Console.ReadLine(); while (!string.IsNullOrEmpty(str)) { int.TryParse(str, out int year); int tg = ((year - 3) % 10) - 1 < 0 ? 9 : ((year - 3) % 10) - 1; int dz = ((year - 3) % 12) - 1 < 0 ? 11 : ((year - 3) % 12) - 1; int sx = ((year - 3) % 12) - 1 < 0 ? 11 : ((year - 3) % 12) - 1; Console.WriteLine($"{_celestialStem[tg]}{_terrestrialBranch[dz]}{_chineseZodiac[sx]}"); Console.WriteLine(); Console.Write("请输入要计算天干地支和生肖的年份: "); str = Console.ReadLine(); } } }}