Sexagenary Cycle(天干地支法表示农历年份)
Sexagenary Cycle
Time Limit: 2 Seconds Memory Limit: 65536 KB
题目链接:zoj 4669
The Chinese sexagenary cycle, also known as the stems-and-branches, is a cycle of sixty terms used for recording days or years. Each term in the sexagenary cycle consists of two Chinese characters, the first representing a term from a cycle of ten known as the heavenly stems and the second from a cycle of twelve known as the earthly branches. The first term (Jiazi) combines the first heavenly stem (Jia) with the first earthly branch (Zi). The second (Yichou) combines the second stem with the second branch. This continues, generating a total of 60 different terms (the least common multiple of ten and twelve), after which the cycle repeats itself.
The ten heavenly stems are Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren and Gui. And the twelve earthly branches are Zi, Chou, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu and Hai. E.g. Xinhai Revolution occurred in 1911, the year of the Xinhai stem-branch in the sexagenary cycle. And this year, namely 2012, is the year of Renchen. Given a year in western year, could you find out which year it is in cyclic year?
Actually, the cyclic year normally changes on the Chinese Lunar New Year, but you can ignore this in this problem.
Input
There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.
Each test case contains a positive integer or a negative integer. A positive integer n indicates n AD (Anno Domini), while a negative integer n indicates -n BC (Before Christ). The absolute values of all integers are strictly less than 10000.
Output
For each test case, output a string -- the corresponding cyclic year.
Sample Input
2
1911
2012
Sample Output
Xinhai
Renchen
References
- http://en.wikipedia.org/wiki/Sexagenary_cycle
- 题目大意:
- 给出一个整数n,代表有n组数据,每组数据都有一个整数,代表年份,年份有负有正,负数代表的是公元前,正数代表的是公元后,求用天干地支法表示出每个年份。
与天干地支相关的资料链接:http://www.pep.com.cn/gzls/xs/lszs/201101/t20110110_1014103.htm
代码:
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char f1[][]={"Xin","Geng","Ji","Wu","Ding","Bing","Yi","Jia","Gui","Ren"};
char g1[][]={"you","shen","wei","wu","si","chen","mao","yin","chou","zi","hai","xu"};
char f2[][]={"Geng","Xin","Ren","Gui","Jia","Yi","Bing","Ding","Wu","Ji","Geng"};
char g2[][]={"shen","you","xu","hai","zi","chou","yin","mao","chen","si","wu","wei","shen"};
int zong;
cin>>zong;
while(zong--)
{
int year;
cin>>year;
if(year>)
{
int yu=year%;
cout<<f2[yu];
yu=year%;
cout<<g2[yu];
cout<<endl;
}
else
{
int yu=(-*year)%;
cout<<f1[yu];
yu=(-*year)%;
cout<<g1[yu];
cout<<endl;
}
}
return ;
}
Sexagenary Cycle(天干地支法表示农历年份)的更多相关文章
- iOS 根据农历日期 获取当前的农历年份 即 干支纪年法算农历年
前言:我国古代是用干支纪年的,近代史上提到的甲午战争.戊戌变法.辛亥革命等名词就是干支纪年.所谓干支就是十天干和十二地支的简称.天干.地支按照一定规则(单配单,双配双)可以搭配成60对,也就是一个甲子 ...
- C# 中国日历 农历 阳历 星座 二十四节气 二十八星宿 节日 天干地支
using System; namespace DotNet.Utilities { /// <summary> /// 农历属性 /// </summary> public ...
- Java 实现输入公历日期输出农历日期、生肖、天干地支、节日、节气等信息
最近的工作中客户要求前台页面展示日历,日历内容包括:农历年月日日.公历年月日.生肖.天干地支.农历节日.公历节日.24节气等信息,之前在网上查找资料关于Java实现方面的文章不少,但是大多数针对节气. ...
- [No0000156]天干地支-狗年我懂,戊戌二字怎么来的?
话说,这几年的年份,总能让人联想到历史课本.比如,2014年是甲午马年,是中日甲午战争120周年.而2018年是戊戌狗年,嗯,戊戌变法也过去120年了…… 狗年相信大家都了解,小观前面两期关于反犬旁和 ...
- Java-获取年月日对应的天干地支
一.概述 本次是以java语言开发为例,计算出年月日对应的天干地支. 二.代码 public class MyDate { /** * 对于年月日的天干地支 */ private int year_g ...
- 十二生肖&天干地支
看相:http://baike.baidu.com/view/833122.htm?fr=aladdin 八字:http://baike.baidu.com/view/17127.htm?fr=ala ...
- jquery 带农历天干地支的日期选择控件
效果图:
- 由.Net类库提供的农历计算
由.Net类库提供的农历计算(C#农历) 2007-11-21 12:47:00 标签:.Net 类库 农历计算 C#农历 休闲 ...
- c#实现万年历示例分享 万年历农历查询
cs.cs(类页面) using System;using System.Collections.Generic;using System.Linq;using System.Web; namespa ...
随机推荐
- BZOJ 3665: maths
Sol 矩阵乘法+快速幂+欧拉定理. 首先观察题目可以发现 \(A_n\) 可以表示成关于 \(K\) 和 \(A_0\) 的几次幂的形式. \(A_0\) 就比较简单了 \(m^n\) 所以第一部分 ...
- wav转aac
//调用neroAacEnc.exe STARTUPINFO si={}; PROCESS_INFORMATION pi={};//隐藏窗口 si.cb=sizeof(si); si.dwFlags= ...
- Python类的特点 (3) :静态方法与类方法
Python中的方法有4种: 1)模块中的全局方法,不属于任何类,用"模块名.方法名"形式调用. 2)类中定义的实例方法,也被称为绑定方法(Bound method),这种方法的第 ...
- PHP使用curl替代file_get_contents
初学php的朋友们,很容易翻一个错误,在写采集程序或者调用api接口总会有线考虑到使用file_get_contents函数来或许内容,程序的访问量不大倒是没什么影响,但是访问量提升了那非常的悲剧了, ...
- Web服务器部署浅析
企业内网站 中小型企业一般将企业宣传网站外包给第三方进行统一设计.部署和运维.大型企业因为访问量和数据量有所增加,部分网站可能具备在线咨询或订单的功能,此类Web服务器采用最通用的IU机架式服务器以降 ...
- 《Head First Servlet JSP》学习笔记二
一. 二. 三. 四. 五. 六. 七. 八. 九. 十. 十一. 十二.
- Strobogrammatic Number
Strobogrammatic Number I A strobogrammatic number is a number that looks the same when rotated 180 d ...
- ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...
- LIGHTSWITCH 连接 MYSQL,中文字符不能保存----解决方法。
使用:dotConnect for MySQL () 作为 数据库连接的PROVIDER , 在 LIGHTSWITCH 中 引用外部的MYSQL 数据源. http://www.devart.co ...
- Appium+Robotframework实现Android应用的自动化测试-6:一个简单的例子
万事具备,只欠编码! 下面看一个简单的示例,这个示例验证Android手机自带的通讯录的添加联系人的操作是否成功.这个例子是Appium官网自带的示例,有兴趣的同学也可以自己下载来研究和学习,下载地址 ...