Skip to content

Instantly share code, notes, and snippets.

@liuxilu
Last active October 25, 2020 11:16
Show Gist options
  • Select an option

  • Save liuxilu/feb7947f71f1676549a049673e8ea7c4 to your computer and use it in GitHub Desktop.

Select an option

Save liuxilu/feb7947f71f1676549a049673e8ea7c4 to your computer and use it in GitHub Desktop.
千字文 百家姓 韵目代日 生肖 天干 原始天干 地支 地支农历月 原始地支 星宿 星禽 六十甲子 太岁星君 纳音表 北斗七星 北斗七星君 北斗九星 北斗九星君
#pragma warning disable CS1591 // XML 注释
using System.Linq;
using System.Text;
namespace System.Globalization.Chinese {
public static class 算数 {
public static decimal ToNum<T>(string s) where T : Enum {
Type enumType = typeof(T);
double numBase = ((int[])Enum.GetValues(enumType)).Distinct().Count();
int len = s.Length;
int lenm = len - 1;
decimal rslt = 0;
for (int i = lenm; i >= 0; i--)
rslt += ((int)Enum.Parse(enumType, new string(s[lenm - i], 1)))
* (int)Math.Pow(numBase, i);
return rslt;
}
public static string ToStr<T>(uint n) where T : Enum {
Type enumType = typeof(T);
uint numBase = (uint)((int[])Enum.GetValues(enumType)).Distinct().Count();
StringBuilder sb = new StringBuilder();
while (n >= numBase) {
sb.Append((T)(object)(int)(n % numBase));
n /= numBase;
}
sb.Append((T)(object)(int)n);
return new string(sb.ToString().Reverse().ToArray());
}
}
public enum 千字文 {
,,,,,,,, ,,,,,宿,,, ,,,,,,,,
,,,,,,調,, ,,,,,,,, ,,,,,,,, //呂
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,, //尌
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,使,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,, //㳃讃
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,,,,, ,,,,,,,, ,,,,,,,,
,,,,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,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,羿,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,宿,,怀,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,寿,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,广,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,
}
public enum 韵目代日 {
= 01, = 01, = 01, = 01, = 01,
= 02, = 02, = 02, = 02, = 02,
= 03, = 03, = 03, = 03, = 03,
= 04, = 04, = 04, = 04, = 04,
= 05, = 05, = 05, = 05, = 05,
= 06, = 06, = 06, = 06, = 06,
= 07, = 07, = 07, = 07, = 07,
= 08, = 08, = 08, = 08, = 08,
= 09, = 09, = 09, = 09, = 09,
= 10, = 10, 贿 = 10, = 10, = 10,
= 11, = 11, = 11, = 11, = 11,
= 12, = 12, = 12, = 12, = 12,
= 13, = 13,
= 14, = 14, = 14, = 14, = 14,
= 15, = 15, = 15, = 15, = 15,
= 16, = 16, = 16,
= 17, = 17, = 17,
= 18, = 18,
= 19, = 19,
= 20, = 20,
= 21, = 21,
= 22, = 22,
= 23, = 23,
= 24, = 24,
= 25, = 25,
= 26, = 26,
= 27, = 27,
= 28, = 28, = 28, = 28, = 28,
= 29, = 29,
= 30, = 30,
= 31, = 31,
}
public enum 生肖 { ,,,,,,,,,,, }
public enum 天干 { ,,,,,,,,, }
public enum 始天干分词 { 阏逢,旃蒙,柔兆,强圉,著雍,屠维,上章,重光,玄黓,昭阳 }
public enum 始天干单字 { ,,,,,,,,,,,,,,,,,,, }
public enum 地支 { ,,,,,,,,,,, }
public enum 地支农历月 { =11,=12,=1,,,,,,,,, }
public enum 始地支分词 { 困顿,赤奋若,摄提格,单阏,执徐,荒落,敦牂,协洽,涒滩,作噩,阉茂,渊献 }
public enum 始地支单字 { ,,,,,,,,,,,,,,,,,,,,,,,,, }
public enum 星宿 { ,,,,,,,,,,,,,,,,,,,,,,,,,,, }
public enum 星禽 { ,,,,,,,,,,,,,,,,,,,,,,,,,鹿,, }
public enum 六十甲子 { 甲子,乙丑,丙寅,丁卯,戊辰,己巳,庚午,辛未,壬申,癸酉,甲戌,乙亥,丙子,丁丑,戊寅,己卯,庚辰,辛巳,壬午,癸未,甲申,乙酉,丙戌,丁亥,戊子,己丑,庚寅,辛卯,壬辰,癸巳,甲午,乙未,丙申,丁酉,戊戌,己亥,庚子,辛丑,壬寅,癸卯,甲辰,乙巳,丙午,丁未,戊申,己酉,庚戌,辛亥,壬子,癸丑,甲寅,乙卯,丙辰,丁巳,戊午,己未,庚申,辛酉,壬戌,癸亥 }
public enum 太岁星君 { 金辨,陈材,耿章,沈兴,赵达,郭灿,王济,李素,刘旺,康志,施广,任保,郭嘉,汪文,鲁先,龙仲,董德,郑但,陆明,魏仁,方章,蒋崇,白敏,封济,邹铛,傅佑,邬桓,范宁,彭泰,徐单,章词,杨仙,管仲,唐查,姜武,谢太,卢秘,杨信,贺谔,皮时,李诚,吴遂,文哲,缪丙,徐浩,程宝,儿秘,叶坚,丘德,朱得,张朝,万清,辛亚,杨彦,黎卿,傅赏,毛梓,石政,洪充,虞程 }
public enum 纳音表 { 海中金,炉中火,大林木,路旁土,剑峰金,山头火,涧下水,城墙土,白蜡金,杨柳木,泉中水,屋上土,霹雳火,松柏木,长流水,沙中金,山下火,平地木,壁上土,金箔金,佛灯火,天河水,林屋木,大驿土,钗钏金,桑柘木,大溪水,沙中土,天上火,石榴木,大海水 }
public enum 北斗七星 { 天枢,天璇,天玑,天权,玉衡,开阳,摇光 }
public enum 北斗七星君 { 贪狼,巨门,禄存,文曲,廉贞,武曲,破军 }
public enum 北斗九星 { 天枢,天璇,天玑,天权,玉衡,开阳,摇光,洞明,隐元 }
public enum 北斗九星君 { 贪狼,巨门,禄存,文曲,廉贞,武曲,破军,左辅,右弼 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment