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