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

没人

Posted by 117474335 at 2010-08-24 00:08:41 on Problem 2002
In Reply To:2121 有人能看下么 怎么老是wrong呢 Posted by:passJava at 2009-07-22 20:52:04
> #include<iostream>
> #include<fstream>
> #include<string>
> #include<strstream>
> using namespace std;
> int num(string str,int &sum,int &ms,int &neg) {
> 	if(str=="negative") {neg=1; return sum;}
> 	if(str=="zero") return sum;
> 	if(str=="one") return sum+1;
> 	if(str=="two") return sum+2;
> 	if(str=="three") return sum+3;
> 	if(str=="four") return sum+4;
> 	if(str=="five") return sum+5;
> 	if(str=="six") return sum+6;
> 	if(str=="seven") return sum+7;
> 	if(str=="eight") return sum+8;
> 	if(str=="nine") return sum+9;
> 	if(str=="ten") return sum+10;
> 	if(str=="eleven") return sum+11;
> 	if(str=="twelve") return sum+12;
> 	if(str=="thirteen") return sum+13;
> 	if(str=="fourteen") return sum+14;
> 	if(str=="fifteen") return sum+15;
> 	if(str=="sixteen") return sum+16;
> 	if(str=="seventeen") return sum+17;
> 	if(str=="eighteen") return sum+18;
> 	if(str=="nineteen") return sum+19;
> 	if(str=="twenty") return sum+20;
> 	if(str=="thirty") return sum+30;
> 	if(str=="forty") return sum+40;
> 	if(str=="fifty") return sum+50;
> 	if(str=="sixty") return sum+60;
> 	if(str=="seventy") return sum+70;
> 	if(str=="eighty") return sum+80;
> 	if(str=="ninety") return sum+90;
> 	if(str=="hundred") return sum*100;
> 	if(str=="thousand") {
> 		ms=ms+sum*1000;
> 		sum=0;
> 		return 0;
> 	}
> 	if(str=="million") {
> 		ms=ms+sum*1000000;
> 		sum=0;
> 		return 0;
> 	}
> 	return 0;
> }
> int main() {
> 	
> 	char *p=new char[400];
> 	int sum=0,i,count,ms,neg;
> //	cout<<a<<endl;
> //	ifstream cin("in.txt",ios::in);
> //	while(cin.peek()!='\n') {
> 	while(true) {
> 		count=0;
> 		sum=0;
> 		ms=0;
> 		neg=0;
> 		cin.getline(p,100,'\n');
> 		if (p[0]=='\0')
> 		{
> 		//	cout<<endl;
> 			break;
> 		}
> 		for(i=0;p[i]!='\0';i++)
> 			if(p[i]==' ') count++;
> 
> 		istrstream istr(p,i);
> 		string *str=new string[count+1];
> 		for(i=0;i<count+1;i++)
> 			istr>>str[i];
> 
> 		for(i=0;i<count+1;i++) {
> 		
> 			sum=num(str[i],sum,ms,neg);
> 		
> 		}
> 		sum=sum+ms;
> 		if(neg==1)
> 			sum=-sum;
> 		
> 		cout<<sum<<endl;
> 		
> 	}
> //	cout<<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