玛雅日期转换

    xiaoxiao2021-03-25  149

    #include<cstdio> #include<cstring> #include<cstdlib> #include <iostream> #include <algorithm> using namespace std; string haab[]={"pop", "no", "zip", "zotz", "tzec",  "xul", "yoxkin", "mol", "chen", "yax",  "zac", "ceh", "mac", "kankin", "muan",  "pax", "koyab", "cumhu", "uayet"};//用string代替了数组的麻烦,再次证明c++的高效 string tzolkin[] = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; int main() {     int n,day,year,month,i;     int days,tday,tmonth,tyear;     string smonth,temp; cin>>n; cout<<n<<endl; while (n>0)     {         cin>>day>>temp>>smonth>>year;//用temp输入.,领教了         days=0;         for (i = 0;  ;i++)         {             if (smonth == haab[i])//计算月份             {                 break;             }         }         month = i;         days = year * 365 + month * 20 + day;//计算总日期         tyear = days/260;//计算年份          days %= 260;         tmonth = days % 20  ;         tday = days % 13 + 1;//+1是因为从一开始         cout<<tday<<" "<<tzolkin[tmonth]<<" "<<tyear<<endl;         n--;     } return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-5788.html

    最新回复(0)