poj_1008 Maya Calendar(模拟题)

【题目】

点击这里

【思路】

模拟题,要求速度,注意细节:strcmp(S1,S2)==0;(表达式)? x:y

【代码】

#include <stdio.h>
#include <string.h>

int main()
{
    long int n,i,j;
    scanf("%d",&n);
    printf("%d\n",n);
    char month[19][10]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
    char month_t[20][10]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
    for (i=0;i<n;i++)
    {
        long int day,year,total=0;
        char mo[10];
        scanf("%d",&day);getchar();
        scanf("%s",mo);
        scanf("%d",&year);
        total+=year*365+day+1;
        for (j=0;j<19;j++){if (strcmp(month[j],mo)==0) break; else total+=20;}
        printf("%d ",(total%13==0)? 13:total%13);
        printf("%s ",month_t[(total%20==0)? 19:total%20-1]);
        printf("%d\n",(total%260>0)? total/260:total/260-1);
    }
    return 0;
}


发布了44 篇原创文章 · 获赞 9 · 访问量 4万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览