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

测试数据都过了有木有,为什么还是WA

Posted by shun_fzll at 2012-07-14 15:32:29 on Problem 2121
#include<iostream>
#include<string>
using namespace std;
int get(string str);
string str1[]={"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"};
int str2[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,40,50,60,70,80,90,100,1000,1000000}; 
int main()
{
	int n=4;
	int sign;
	while(n--)//真心不知道要测几组数据
	{
		
		
		int sum=0,hsum=0,tsum=0,msum=0;
		while(1)//多个单词
		{
			
			string str;
			cin>>str;
			if(str=="negative")
				sign=-1;
			else
				sign=1;
			if(str=="hundred")
			{
				hsum=sum*100;
				sum=0;
			}
			else if(str=="thousand")
			{
				tsum=(hsum+sum)*1000;
				hsum = 0;
				sum=0;
			}
			else if(str=="million")
			{
				msum=(hsum+tsum+sum)*1000000;
				hsum=tsum=0;
				sum=0;
			}
			else 
			{
				sum+=get(str);
			}
			
			if(getchar()=='\n')break;
			
		}
		sum+=(hsum+tsum+msum);

		cout<<(sign)*(sum)<<endl;
				
	}
	return 0;

}
int get(string str)//翻译
{
	int i;
	for(i=0;i<31;i++)
		if(str==str1[i])
			break;
	return str2[i];
}

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