北大ACM(POJ1008-Maya Calendar)

Question:http://poj.org/problem?id=1008
问题点:日历转换。
 1 Memory: 280K        Time: 16MS
 2 Language: C++        Result: Accepted
 3 
 4 #include <iostream>
 5 #include <string.h>
 6 #include <malloc.h>
 7 
 8 using namespace std;
 9 const char* Haab_Month[19]={
10     "pop", "no", "zip", "zotz", "tzec", "xul",
11     "yoxkin", "mol", "chen", "yax", "zac", "ceh",
12     "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"
13 };
14 const char* Tzolkin_DayName[20]={
15     "imix", "ik", "akbal", "kan", "chicchan",
16     "cimi", "manik", "lamat", "muluk", "ok",
17     "chuen", "eb", "ben", "ix", "mem",
18     "cib", "caban", "eznab", "canac", "ahau"
19 };
20 struct Haab{
21     int day;
22     int month;
23     int year;
24 };
25 struct Tzolkin{
26     int day;
27     int dayn;
28     int year;
29 };
30 int main()
31 {
32     int N;
33     cin>>N;
34     cout<<N<<endl;
35     for(int i=0;i<N;i++)
36     {
37         Haab h1;
38         float day;
39         char *month=(char *)malloc(sizeof(char)*10);
40         cin>>day>>month>>h1.year;
41         h1.day=(int)day;
42         for(int j=0;j<19;j++)
43         {
44             if(strcmp(month,Haab_Month[j])==0)
45             {
46                 h1.month=j;
47                 break;
48             }
49         }
50         int cnt=h1.year*365+h1.month*20+h1.day;
51         Tzolkin b1;
52         b1.year=cnt/260;
53         b1.dayn=cnt%20;
54         b1.day=cnt%13+1;
55         cout<<b1.day<<" "<<Tzolkin_DayName[b1.dayn]<<" "<<b1.year<<endl;
56     }
57     return 0;
58 }

 

 

转载于:https://www.cnblogs.com/TYcnblogs/p/poj1008.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值