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 afc163 at 2006-04-04 20:38:54 on Problem 2608
//acm 2608
//Soundex
#include <iostream>
#include <cstring>
using namespace std;

const int size = 20;

int main()
{
	char word[size];
	int last = 0;
	enum {n1=1 , n2 , n3 , n4 , n5 , n6};
	

	while(cin>>word)
	{
		int k=(strlen(word) >= size ? size : strlen(word));
		for(int j=0 ; j < k ; j++)
		{
			switch(*(word + j)) 
			{
				case 'B':
				case 'F':
				case 'P':
				case 'V': 
					{
						if(last != n1)
						{
							last = n1;
							cout<<n1;
						}
						break;
					}
				case 'C':
				case 'G':
				case 'J':
				case 'K':
				case 'Q':
				case 'S':
				case 'X':
				case 'Z':
					{
						if(last != n2)
						{
							last = n2;
							cout<<n2;
						}
						break;
					}
				case 'D':
				case 'T':
					{
						if(last != n3)
						{
							last = n3;
							cout<<n3;
						}
						break;
					}
				case 'L':
					{
						if(last != n4)
						{
							last = n4;
							cout<<n4;
						}
						break;
					}
				case 'M':
				case 'N':
					{
						if(last != n5)
						{
							last = n5;
							cout<<n5;
						}
						break;
					}
				case 'R':
					{
						if(last != n6)
						{
							last = n6;
							cout<<n6;
						}
						break;
					}
				default: last = 0;
			}
		}
		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