Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为毛老是runtime error?

Posted by 161110125 at 2013-10-16 12:28:03 on Problem 1008
#include <iostream>
#include <cstring>
using namespace std;
char *monthNamesH[] = {"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char *namesT[] = {"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};

int getIndex(char*src[],int srclen,char*str)
{
	int i;
	for (i = 0; i < srclen; i++)
	{
		if (strcmp(src[i],str) == 0)
		{
			return i;
		}
	}
	return -1;
}

int main()
{
	int caseCnt=0,i=0;
	int hday=0,hmonth=0,hyear=0;
	int tperiod=0,tnumber=0,tyear=0;
	int totalDays=0;
	char strMonth[10] = {0};
	cin>>caseCnt;
	cout<<caseCnt<<endl;
	for (i = 0; i < caseCnt; i++)
	{
		cin>>hday;
		cin.ignore();
		cin>>strMonth>>hyear;
		hmonth = getIndex(monthNamesH,19,strMonth);
		totalDays = hyear*365+hmonth*20+hday+1;
		tyear = totalDays/260;
		if (tyear%260==0 && tyear>0) tyear--;
		tperiod = (totalDays - tyear*260-1)%20;
		tnumber = (totalDays - tyear*260)%13;
		cout<<tnumber<<" "<<namesT[tperiod]<<" "<<tyear<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator