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 Windy3721 at 2008-07-06 16:11:36 on Problem 2608
#include <iostream>
using namespace std;

int main()
{
 	char word[23];
 	char code[23];
	while(cin>>word)
	{
	    int j=0, pre=0;;
	 	for(int i=0; word[i]!='\0'; i++)
		{
		 	if((word[i]=='B' || word[i]=='F' || word[i]=='P' || word[i]=='V') && pre!=1)
			{   
				code[j++] = '1';
				pre = 1;
			}
			else if((word[i]=='C' || word[i]=='G' || word[i]=='J' || word[i]=='K' || word[i]=='Q'
	             || word[i]=='S' || word[i]=='X' || word[i]=='Z') && pre!=2)
		    {
			    code[j++] = '2';
				pre = 2; 	 
 	        }
 	        else if((word[i]=='D' || word[i]=='T') && pre!=3)
 	        {
			 	code[j++] = '3';
				pre = 3; 	 
		    }
		    else if(word[i]=='L' && pre!=4)
		    {
			    code[j++] = '4';
				pre = 4; 	 
		    }
		    else if((word[i]=='M' || word[i]=='N') && pre!=5)
		    {
			 	code[j++] = '5';
				pre = 5; 	 
		    }
		    else if(word[i]=='R' && pre!=6)
		    {
			 	code[j++] = '6';
				pre = 6; 	 
 		    }
 		    else if(word[i]=='A' || word[i]=='E' || word[i]=='I' || word[i]=='O' || word[i]=='U'
 		         || word[i]=='H' || word[i]=='W')
 		        pre = 0;
		}  
		code[j] = '\0';
		cout<<code<<endl;				
	} 	
	
	system("pause");
	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