poj 2608 Soundex

简介:

直接上代码吧,题目很简单:

#include<iostream>

using namespace std;

char a[21];

int kan(char a)
{
	if(a=='B'||a=='F'||a=='P'||a=='V') return 1;
	if(a=='C'||a=='G'||a=='J'||a=='K'||a=='Q'||a=='S'||a=='X'||a=='Z') return 2;
	if(a=='D'||a=='T') return 3;
	if(a=='L') return 4;
	if(a=='M'||a=='N') return 5;
	if(a=='R') return 6;
	else return 0;
}


int main()
{
	while(gets(a))
	{
		int l=strlen(a);
		for(int i=0,now=0,last=0;l-i;i++)
		{
			now=kan(a[i]);
			if(now&&now!=last)
			{
				cout<<now;
			}
			last=now;
		}
		cout<<endl;
	}
}



相关文章
|
人工智能 机器学习/深度学习
poj 3664
http://poj.org/problem?id=3664 进行两轮选举,第一轮选前n进入第二轮,第二轮选最高   #include #include using namespace std; struct vote { int a,b; int c; ...
705 0
POJ-1003-hangover
Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length.
737 0
|
机器学习/深度学习
POJ 2487 Stamps
Description Background Everybody hates Raymond. He’s the largest stamp collector on planet earth and because of that he always makes fun of all the others at the stamp collector parties.
1035 0
POJ 2262 Goldbach&#39;s Conjecture
Problem Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the foll...
968 0
|
机器学习/深度学习
|
机器学习/深度学习
|
测试技术