zoukankan      html  css  js  c++  java
  • 【POJ】1008 Maya Calendar

    参考:https://blog.csdn.net/u011392408/article/details/28866779

    https://blog.csdn.net/qq_36424540/article/details/78234240

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 using namespace std;
     5 int d,y;
     6 string s;
     7 //string sh[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu"};
     8 //string st[]={"","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
     9 char sh[25][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};//用strig数组过不了,望来个大神解答一下!
    10 char st[25][10]={"","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
    11 int turn(int dd,string ss,int yy)//求总的天数
    12 {
    13     int days,i;
    14     for (i=0;ss!=sh[i];i++);
    15     days=20*i+dd+yy*365;
    16     return days;
    17 }
    18 int main()
    19 {
    20     int t;
    21 //    freopen("F:\ACM\text.txt","r",stdin);
    22     while (cin>>t)
    23     {
    24         cout<<t<<endl;
    25         while (t--)
    26         {
    27             char c;
    28             cin>>d>>c>>s>>y;
    29             int real=turn(d,s,y)+1;
    30             int yt=real/260,days=real%260;//yt为转化后的年
    31             if (days==0)
    32             {
    33                 yt--;
    34                 days=260;
    35             }
    36             int dt=days%13;//int dt=days%13+1,dn=days%20+1这样写是不对的!
    37             if (dt==0)
    38             {
    39                 dt=13;
    40             }
    41             int dn=days%20;
    42             if (dn==0)
    43             {
    44                 dn=20;
    45             }
    46             cout<<dt<<' '<<st[dn]<<' '<<yt<<endl;
    47         }
    48     }
    49 
    50     return 0;
    51 }
  • 相关阅读:
    ## js 性能 (未完。。。)
    React 创建元素的几种方式
    Json 与 javascript 对象的区别
    js 基本数据类型
    第十三章 事件
    第十二章 DOM2和DOM3
    第十一章 DOM扩展
    第十章 DOM
    第八章 BOM
    第七章 函数表达式
  • 原文地址:https://www.cnblogs.com/hemeiwolong/p/9394949.html
Copyright © 2011-2022 走看看