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

Re:各位大牛们帮我看看吧,WA了8次了,实在不知道错在哪里…… 空行也没有0

Posted by wsbear at 2007-08-11 23:43:03 on Problem 2121
In Reply To:各位大牛们帮我看看吧,WA了8次了,实在不知道错在哪里…… 空行也没有0 Posted by:Asp at 2006-10-28 09:45:01
> /*
> six
> negative seven hundred twenty nine
> one million one hundred one
> eight hundred fourteen thousand twenty two
> one hundred ninety thousand million
> one million one hundred eleven thousand one hundred eleven
> nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine
> negative nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine
> zero
> negative zero
> one thousand thousand
> one thousand hundred
> */
> 
> #include < stdio.h >
> #include < string.h >
> 
> char nums[32][20]=
> {
> 	"zero","one","two","three","four","five","six","seven","eight","nine","ten",
> 	"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen",
> 	"nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety",
> 	"hundred","thousand","million","negative"
> };
> 
> __int64 numn(char *s)
> {
> 	__int64 i=0;
> 	while(strcmp(s,nums[i])!=0&&i<31) i++;
> 	if(i==31) return -1;
> 	if(20<i&&i<28) return (i-18)*10;
> 	return i;////////////////没有return 28..30啊...而且gets好象也不行的...用cin.getline()...
> }
> 
> int main()
> {
> 	char s[1000]={0},*s1;
> 	__int64 resmil,reshun,restho,isneg,n,restemp;
> 	while(1)
> 	{
> 		gets(s);
> 		if(strcmp(s,"")==0) break;
> 		resmil=reshun=restho=isneg=n=restemp=0;
> 		s1=strtok(s," ");
> 		while(s1)
> 		{
> 			n=numn(s1);
> 			if(n==-1) isneg=1;
> 			else if(n==28) {if(reshun) reshun*=100;reshun+=restemp;restemp=0;}
> 			else if(n==29) {if(restho) restho*=1000;restho+=restemp+reshun*100;restemp=reshun=0;}
> 			else if(n==30) {if(resmil) resmil*=1000000;resmil+=restemp+restho*1000+reshun*100;restemp=reshun=restho=0;}
> 			else
> 				restemp+=n;
> 			s1=strtok(NULL," ");
> 		}
> 		if(isneg&&resmil*1000000+restho*1000+reshun*100+restemp) putchar('-');
> 		printf("%I64d\n",resmil*1000000+restho*1000+reshun*100+restemp);
> 	}
> 	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