zoukankan      html  css  js  c++  java
  • POJ1008Maya Calendar

    http://poj.org/problem?id=1008&lang=default&change=true

    这个题倒是不难,就是麻烦一点,但是还WA了几次都是因为处理天数的时候没处理好,因为Haab这个日历日期是从0开始的,所以当第一年的最后一天第364天,而如果输入的恰好是365天应该是第二年的,所以,那个天数要放在下面处理

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 using namespace std ;
     5 int main()
     6 {
     7     int n ;
     8     scanf("%d",&n) ;
     9     printf("%d
    ",n);
    10     for(int i = 1 ; i <= n ; i++)
    11     {
    12         int day,year ;
    13         char month[11];
    14         scanf("%d",&day) ;
    15         getchar();
    16         cin>>month ;
    17         cin>>year ;
    18         int mon ;
    19         if(strcmp(month,"pop")==0) mon = 1 ;
    20         if(strcmp(month,"no")==0) mon = 2 ;
    21         if(strcmp(month,"zip")==0) mon = 3 ;
    22         if(strcmp(month,"zotz")==0) mon = 4 ;
    23         if(strcmp(month,"tzec")==0) mon = 5 ;
    24         if(strcmp(month,"xul")==0) mon = 6 ;
    25         if(strcmp(month,"yoxkin")==0) mon = 7 ;
    26         if(strcmp(month,"mol")==0) mon = 8 ;
    27         if(strcmp(month,"chen")==0) mon = 9 ;
    28         if(strcmp(month,"yax")==0) mon = 10 ;
    29         if(strcmp(month,"zac")==0) mon = 11 ;
    30         if(strcmp(month,"ceh")==0) mon = 12 ;
    31         if(strcmp(month,"mac")==0) mon = 13 ;
    32         if(strcmp(month,"kankin")==0) mon = 14 ;
    33         if(strcmp(month,"muan")==0) mon = 15 ;
    34         if(strcmp(month,"pax")==0) mon = 16 ;
    35         if(strcmp(month,"koyab")==0) mon = 17 ;
    36         if(strcmp(month,"cumhu")==0) mon = 18 ;
    37         if(strcmp(month,"uayet")==0) mon = 19 ;
    38         int days = (year*365)+(mon-1)*20+day;
    39         printf("%d ",days%260%13+1);
    40         int Tdays = days%260%20+1 ;
    41         if(Tdays == 1) cout<<"imix";
    42         if(Tdays == 2) cout<<"ik";
    43         if(Tdays == 3) cout<<"akbal";
    44         if(Tdays == 4) cout<<"kan";
    45         if(Tdays == 5) cout<<"chicchan";
    46         if(Tdays == 6) cout<<"cimi";
    47         if(Tdays == 7) cout<<"manik";
    48         if(Tdays == 8) cout<<"lamat";
    49         if(Tdays == 9) cout<<"muluk";
    50         if(Tdays == 10) cout<<"ok";
    51         if(Tdays == 11) cout<<"chuen";
    52         if(Tdays == 12) cout<<"eb";
    53         if(Tdays == 13) cout<<"ben";
    54         if(Tdays == 14) cout<<"ix";
    55         if(Tdays == 15) cout<<"mem";
    56         if(Tdays == 16) cout<<"cib";
    57         if(Tdays == 17) cout<<"caban";
    58         if(Tdays == 18) cout<<"eznab";
    59         if(Tdays == 19) cout<<"canac";
    60         if(Tdays == 20) cout<<"ahau";
    61         //int Tyears = (year*365)/260 ;
    62         int Tyears = days/260;
    63         cout<<" "<<Tyears<<endl ;
    64     }
    65     return 0 ;
    66 }
    View Code
  • 相关阅读:
    02_虚拟机参数
    01_java虚拟机基础入门
    03_模板消息
    Redis 实现分布式锁
    01_微信小程序支付
    python产生随机字符串
    输出的编码
    jmeter MD5加密
    vscode 插件推荐
    appium自动化安装(二)
  • 原文地址:https://www.cnblogs.com/luyingfeng/p/3229991.html
Copyright © 2011-2022 走看看