标签:
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 }
标签:
原文地址:http://www.cnblogs.com/TYcnblogs/p/poj1008.html