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 l2011012181 at 2013-07-22 11:07:43 on Problem 2121
#include <stdio.h>
#include <string.h>

int main()
{
	char ch[150];
	int x,num,i,k;
	while(gets(ch))
	{
		if(!strcmp(ch,""))
			break;
		x=0;num=0;i=0;k=0;
		for(i = 0; i<strlen(ch); i++)
		{
			if(ch[i]==' ')
			{
				ch[i]=0;
				if(!strcmp(&ch[k],"negative"))printf("-");
				else if(!strcmp(&ch[k],"zero"))x+=0;
				else if(!strcmp(&ch[k],"one"))x+=1;
				else if(!strcmp(&ch[k],"two"))x+=2;
				else if(!strcmp(&ch[k],"three"))x+=3;
				else if(!strcmp(&ch[k],"four"))x+=4;
				else if(!strcmp(&ch[k],"five"))x+=5;
				else if(!strcmp(&ch[k],"six"))x+=6;
				else if(!strcmp(&ch[k],"seven"))x+=7;
				else if(!strcmp(&ch[k],"eight"))x+=8;
				else if(!strcmp(&ch[k],"nine"))x+=9;
				else if(!strcmp(&ch[k],"ten"))x+=10;
				else if(!strcmp(&ch[k],"eleven"))x+=11;
				else if(!strcmp(&ch[k],"twelve"))x+=12;
				else if(!strcmp(&ch[k],"thirteen"))x+=13;
				else if(!strcmp(&ch[k],"fourteen"))x+=14;
				else if(!strcmp(&ch[k],"fifteen"))x+=15;
				else if(!strcmp(&ch[k],"sixteen"))x+=16;
				else if(!strcmp(&ch[k],"seventeen"))x+=17;
				else if(!strcmp(&ch[k],"eighteen"))x+=18;
				else if(!strcmp(&ch[k],"nineteen"))x+=19;
				else if(!strcmp(&ch[k],"twenty"))x+=20;
				else if(!strcmp(&ch[k],"thirty"))x+=30;
				else if(!strcmp(&ch[k],"forty"))x+=40;
				else if(!strcmp(&ch[k],"fifty"))x+=50;
				else if(!strcmp(&ch[k],"sixty"))x+=60;
				else if(!strcmp(&ch[k],"seventy"))x+=70;
				else if(!strcmp(&ch[k],"eighty"))x+=80;
				else if(!strcmp(&ch[k],"ninety"))x+=90;
				else if(!strcmp(&ch[k],"hundred"))x*=100;
				else if(!strcmp(&ch[k],"thousand"))
				{
					num+=x*1000;
					x=0;
				}	
				else if(!strcmp(&ch[k],"millon"))
				{
					num+=x*1000000;
					x=0;
				}
				ch[i]=' ';
				k=i+1;
			}
		}
		if(!strcmp(&ch[k],"negative"))printf("-");
		else if(!strcmp(&ch[k],"zero"))x+=0;
		else if(!strcmp(&ch[k],"one"))x+=1;
		else if(!strcmp(&ch[k],"two"))x+=2;
		else if(!strcmp(&ch[k],"three"))x+=3;
		else if(!strcmp(&ch[k],"four"))x+=4;
		else if(!strcmp(&ch[k],"five"))x+=5;
		else if(!strcmp(&ch[k],"six"))x+=6;
		else if(!strcmp(&ch[k],"seven"))x+=7;
		else if(!strcmp(&ch[k],"eight"))x+=8;
		else if(!strcmp(&ch[k],"nine"))x+=9;
		else if(!strcmp(&ch[k],"ten"))x+=10;
		else if(!strcmp(&ch[k],"eleven"))x+=11;
		else if(!strcmp(&ch[k],"twelve"))x+=12;
		else if(!strcmp(&ch[k],"thirteen"))x+=13;
		else if(!strcmp(&ch[k],"fourteen"))x+=14;
		else if(!strcmp(&ch[k],"fifteen"))x+=15;
		else if(!strcmp(&ch[k],"sixteen"))x+=16;
		else if(!strcmp(&ch[k],"seventeen"))x+=17;
		else if(!strcmp(&ch[k],"eighteen"))x+=18;
		else if(!strcmp(&ch[k],"nineteen"))x+=19;
		else if(!strcmp(&ch[k],"twenty"))x+=20;
		else if(!strcmp(&ch[k],"thirty"))x+=30;
		else if(!strcmp(&ch[k],"forty"))x+=40;
		else if(!strcmp(&ch[k],"fifty"))x+=50;
		else if(!strcmp(&ch[k],"sixty"))x+=60;
		else if(!strcmp(&ch[k],"seventy"))x+=70;
		else if(!strcmp(&ch[k],"eighty"))x+=80;
		else if(!strcmp(&ch[k],"ninety"))x+=90;
		else if(!strcmp(&ch[k],"hundred"))x*=100;
		else if(!strcmp(&ch[k],"thousand"))
		{
			num+=x*1000;
			x=0;
		}	
		else if(!strcmp(&ch[k],"millon"))
		{
			num+=x*1000000;
			x=0;
		}
		printf("%d\n",x+num);
	}
	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