赞
踩
10天干:庚辛壬癸甲乙丙丁戊己
对其编码:0 1 2 3 4 5 6 7 8 9
12地支: 申酉戌亥子丑寅卯辰巳午未
对其编码:0 1 2 3 4 5 6 7 8 9 10 12
如2014年,取各位数字4,则天干对应编码为甲。
用12去除2014得余数10,则地支对应编码为午。即,2014为甲午年。
- char TianGan[]={"庚辛壬癸甲乙丙丁戊己"};
- char DiZhi[]={"申酉戌亥子丑寅卯辰巳午未"};
- int year,tg,dz;
- cout<<"请输入年份"<<endl;
- cin>>year;
- tg=year%10;
- dz=year%12;
- string s1,s2;
- s1.assign(TianGan,tg*2,2);
- s2.assign(DiZhi,dz*2,2);
- cout<<year<<"年是:"<<s1<<""<<s2;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。