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:这代码真是简单易懂,借鉴了牛人的思想就是不一样。

Posted by 201431720023 at 2015-08-02 16:33:43 on Problem 2121
In Reply To:这代码真是简单易懂,借鉴了牛人的思想就是不一样。 Posted by:139074241 at 2015-01-30 16:58:06
> #include<iostream>
> #include<string>
> #include<cstdio>
> using namespace std;
> int main()
> {
> 	string s;
> 	int sum=0,ans=0;
> 	char ch;
> 	while(cin>>s)
> 	{
> 		if(s=="negative")
> 			cout<<"-";
> 		else if(s=="zero")
> 			sum+=0;
> 		else if(s=="one")
> 			sum+=1;
> 		else if(s=="two")
> 			sum+=2;
> 		else if(s=="three")
> 			sum+=3;
> 		else if(s=="four")
> 			sum+=4;
> 		else if(s=="five")
> 			sum+=5;
> 		else if(s=="six")
> 			sum+=6;
> 		else if(s=="seven")
> 			sum+=7;
> 		else if(s=="eight")
> 			sum+=8;
> 		else if(s=="nine")
> 			sum+=9;
> 		else if(s=="ten")
> 			sum+=10;
> 		else if(s=="eleven")
> 			sum+=11;
> 		else if(s=="twelve")
> 			sum+=12;
> 		else if(s=="thirteen")
> 			sum+=13;
> 		else if(s=="fourteen")
> 			sum+=14;
> 		else if(s=="fifteen")
> 			sum+=15;
> 		else if(s=="sixteen")
> 			sum+=16;
> 		else if(s=="seventeen")
> 			sum+=17;
> 		else if(s=="eighteen")
> 			sum+=18;
> 		else if(s=="nineteen")
> 			sum+=19;
> 		else if(s=="twenty")
> 			sum+=20;
> 		else if(s=="thirty")
> 			sum+=30;
> 		else if(s=="forty")
> 			sum+=40;
> 		else if(s=="fifty")
> 			sum+=50;
> 		else if(s=="sixty")
> 			sum+=60;
> 		else if(s=="seventy")
> 			sum+=70;
> 		else if(s=="eighty")
> 			sum+=80;
> 		else if(s=="ninety")
> 			sum+=90;
> 		else if(s=="hundred")
> 			sum*=100;
> 		else if(s=="thousand")
> 		{
> 			ans+=sum*1000;
> 			sum=0;
> 		}
> 		else if(s=="million")
> 		{
> 			ans+=sum*1000000;
> 			sum=0;
> 		}
> 		ch=getchar();
> 		if(ch=='\n')
> 		{
> 			cout<<ans+sum<<endl;
> 			sum=0;
> 			ans=0;
> 		}
> 	}
> 	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