一道ACM题目.看看代码,为什么检测的时候总WRONG ANSWER.

1326.Soundex-------------------------------------------------------------------------... 1326. Soundex
--------------------------------------------------------------------------------
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 4945 Accepted Runs: 1732 Multiple test files

--------------------------------------------------------------------------------

Soundex coding groups together words that appear to sound alike based on their spelling. For example, "can" and "khawn", "con" and "gone" would be equivalent under Soundex coding.
Soundex coding involves translating each word into a series of digits in which each digit represents a letter:

1 represents B, F, P, or V
2 represents C, G, J, K, Q, S, X, or Z
3 represents D or T
4 represents L
5 represents M or N
6 represents R

The letters A, E, I, O, U, H, W, and Y are not represented in Soundex coding, and repeated letters with the same code digit are represented by a single instance of that digit. Words with the same Soundex coding are considered equivalent.
Each line of input contains a single word, all upper case, less than 20 letters long. For each line of input, produce a line of output giving the Soundex code.

Sample Input
KHAWN
PFISTER
BOBBY

Output for Sample Input
25
1236
11

我写的代码如下:
#include <iostream>
#include <string>
using namespace std;

int main()
{
for(int K=0;K<1002;K++)
{
char a[30];
cin>>a;
for(int i=0;i<strlen(a);i++)
{
if((a[i]=='B'||a[i]=='F'||a[i]=='P'||a[i]=='V')&&(a[i+1]!='B'&&a[i+1]!='F'&&a[i+1]!='P'&&a[i+1]!='V'))
cout<<1;
if((a[i]=='C'||a[i]=='G'||a[i]=='J'||a[i]=='K'||a[i]=='Q'||a[i]=='S'
||a[i]=='X'||a[i]=='Z')&&(a[i+1]!='C'&&a[i+1]!='G'&&a[i+1]!='J'&&a[i+1]!='K'&&a[i+1]!='Q'&&a[i+1]!='S'
&&a[i+1]!='X'&&a[i+1]!='Z'))
cout<<2;
if((a[i]=='D'||a[i]=='T')&&(a[i+1]!='D'&&a[i+1]!='T'))
cout<<3;
if(a[i]=='L'&&a[1+1]!='L')
cout<<4;
if((a[i]=='M'||a[i]=='N')&&(a[i+1]!='M'&&a[i+1]!='N'))
cout<<5;
if(a[i]=='R'&&a[i+1]!='R')
cout<<6;

}
cout<<endl;
}
return 0;
}
代表的数字相同就只要一个
展开
 我来答
huanyingzixin
2010-11-11
知道答主
回答量:44
采纳率:0%
帮助的人:13.7万
展开全部
我英文不好 题目意思是连续相同的字母只要一个 还是只要代表的数字相同就只要一个啊
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2010-11-21
展开全部
#include<iostream>
#include<string>
using namespace std;
int main( )
{
while(1)
{
int n=0; char c; string answer=
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式