ZOJ3594 Sexagenary Cycle

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3594


输入年份,输出对应的天干地支,没有公元元年。维基百科上干支条目有错误。


#include
#include
#include
#include
#include
using namespace std;

unsigned long long ans,nn;

int main()
{
    char a[11][100]={"Gui","Jia","Yi","Bing","Ding","Wu","Ji","Geng","Xin","Ren","Gui"};
    char b[13][100]={"hai","zi","chou", "yin", "mao","chen", "si", "wu", "wei", "shen", "you", "xu","hai"};

    int t,n,m;
    cin>>t;
    for (int k=1;k<=t;k++)
    {
        cin>>n;

        if (n<0) n++;
        n+=216000;
        if (n>0)
        {
            n-=3;
            int m1;

            m=n%10;
            m1=n%12;
            printf("%s%s\n",a[m],b[m1]);
        }

    }

    return 0;
}


你可能感兴趣的:(ZOJ3594 Sexagenary Cycle)