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

为什么用printf输出就WA,改用stringstream,然后一起输出就AC了

Posted by hsujamy at 2010-08-09 20:50:51 on Problem 1008
#include <iostream>
#include <sstream>
using namespace std;
char haab[][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char tzolkin[][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok", "chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int ha[999];
int main()
{
	stringstream mystream;
	int test,i,j,k;
	for (i=0;i!=19;i++)
	{
		int sum=0;
		for (j=0;j!=strlen(haab[i]);j++)
		{
			sum+=haab[i][j];
		}
		ha[sum]=i;
	}
	scanf("%d",&test);
        //这里
	//printf("%d\n",test);
	mystream<<test<<endl;
	for (i=0;i!=test;i++)
	{
		int hday,hmonth,hyear,allday;
		char hm[10];
		double a;
		scanf("%lf%s%d",&a,hm,&hyear);
		hday=int(a);
		int s=0;
		for (j=0;j!=strlen(hm);j++) s+=hm[j];
		hmonth=ha[s];
		allday=hyear*365+hmonth*20+hday;
		int tnum,tday,tyear;
		tyear=allday/260;
		allday%=260;
		tday=allday%20;
		tnum=allday%13+1;
                //这里
		//printf("%d %s %d\n",tnum,tzolkin[tday],tyear);
		mystream<<tnum<<" "<<tzolkin[tday]<<" "<<tyear<<endl;
	}
	cout<<mystream.str();
	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