1008 maya calendar

代码可以输出正确结果。但提交平台显示runtime error

 1 #include<iostream>
 2 #include<string>
 3 #include<string.h>
 4 using namespace std;
 5 struct node{
 6     int number,newyear;
 7     string k;
 8 }h[10];
 9 int main(){
10     float numberday=0.0;
11     int n,year,day=0;
12     char month[20];
13     string k;
14     cin>>n;
15     char hmonth[20][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
16     char tday[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib",
17         "caban","rznab","canac","ahau"};
18     for(int x=1;x<=n;x++){
19         cin>>numberday;
20         cin>>month;
21         cin>>year;
22         for(int i=0;i<=19;i++){
23             if(strcmp(month,hmonth[i])==0){
24                     day=(int)numberday+i*20+1+year*365;
25                     h[x].k=tday[day%20-1];
26                     h[x].number=day%13;
27                     h[x].newyear=day/260;
28             }
29         }
30     }
31     cout<<n<<endl;
32     for(int i=1;i<=n;i++)
33         cout<<h[i].number<<" "<<h[i].k<<" "<<h[i].newyear<<endl; 
34     return 0;
35 }

 

posted on 2019-09-11 16:13  姜姜糖  阅读(178)  评论(0编辑  收藏  举报