Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
【更正】大神帮忙看看 测试了我能找到的所有数据都是正确的,提交却是runtime error,无力了跪求帮看了!!!!#include<iostream> #include<string> #include<string.h> using namespace std; bool equal(char *s1, char *s2){ int i = 0; while((s1[i] == s2[i])&& (s1[i] != '\0')){ ++i; } if((s1[i] == '\0')&& (s2[i] == '\0')){ return true; }else{ return false; } } struct node{ int year; int month; int day; node(int i = 0, int j = 0, int k = 0){ year = i; month = j; day = k; } }; int days(int day, char *month, int year){ char *s[] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"}; int m = 0; while(!equal(month, s[m])){ ++m; } int days = m*20 + day + 365*year + 1; return days; } node print(int days){ int year = days/260; int flag = 0; if(year*260 == days){ year = year - 1; flag = 1; } int day; int num; if(flag){ day = 19; num = 13; }else{ day = ((days - 260*year)%20 - 1); num = (days - 260*year)%13; } if(num == 0){ num = 13; } node p; p.day = num; p.year = year; p.month = day; return p; } int main(){ char *s[] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int n; cin>>n; node *pt = new node[n]; int year; string day; string month; int temp; int num; for(int k = 0; k < n; ++k){ cin>>day; int m = day.size(); if(m == 3)temp = 10*(day[0] - '0') + (day[1] - '0'); if(m == 2)temp = (day[0] - '0'); cin>>month; cin>>year; char *p = new char[month.size()]; for(int i = 0; i < month.size(); ++i){ p[i] = month[i]; } p[month.size()] = '\0'; pt[k] = print(days(temp,p,year)); } cout<<n<<endl; for(int i = 0; i < n; ++i){ cout<<pt[i].day<<" "<<s[pt[i].month]<<" "<<pt[i].year<<endl; } while(1); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator