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 ...
随机推荐
- OpenGL官方教程——着色器语言概述
OpenGL官方教程——着色器语言概述 OpenGL官方教程——着色器语言概述 可编程图形硬件管线(流水线) 可编程顶点处理器 可编程几何处理器 可编程片元处理器 语言 可编程图形硬件管线(流水线) ...
- JavaWeb出现404一个很隐蔽的原因
- JAVA调用动态链接库DLL之JNative学习
package com.ehfscliax; import java.io.UnsupportedEncodingException;import java.net.URLEncoder;import ...
- jQuery工作原理
jQuery的开篇声明里有一段非常重要的话:jQuery是为了改变javascript的编码方式而设计的.从这段话可以看出jQuery本身并不是UI组件库或其他的一般AJAX类库.jQuery改变ja ...
- sruts2 自定义类型转换器
1.1.1 Struts2中自定义类型转换器:(了解) 类型转换的过程是双向的过程: JSP---->Action参数提交:String---Date. Action---->JSP ...
- How to take partial screenshot with Selenium WebDriver in python
from selenium import webdriver from PIL import Image fox = webdriver.Firefox() fox.get('http://stack ...
- ios The App Life Cycle
先推荐ios 必读文章 App Programming Guide for iOS ,请在苹果官网搜索,并仔细阅读所有内容 State Description Not running The app ...
- ios UIButton shadowcolor 导致黑边问题
注意这个属性,会导致按钮文字有一定黑边,其实就是阴影效果,如果不是想要的效果,应该把它设置为clearcolor.这种情况在亮色背景下比较突出.
- August 20th 2016 Week 34th Saturday
Everything you see exists together in a delicate balance. 你所看到的一切都处于微妙的平衡中. Seeking for balance in l ...
- VS中新建类
通常我们在VS中添加类,比如要声明一个car的类 我们通常在新建的时候会写成CCar,虽然新建出来的文件的名词是car,但是我们使用这个类来声明一个类的时候, 是CCar car; 如果新建类写成Ca ...