Soundex(map映射)
来源:互联网 发布:网络歌曲红尘歌曲 编辑:程序博客网 时间:2024/05/18 22:10
Soundex
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9494 Accepted: 4720
Description
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:
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.
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.
Input
Each line of input contains a single word, all upper case, less than 20 letters long.
Output
For each line of input, produce a line of output giving the Soundex code.
Sample Input
KHAWNPFISTERBOBBY
Sample Output
25123611
Source
Waterloo local 1999.09.25
#include<cstdio>#include<iostream>#include<cstring>#include<map>using namespace std;int main(){ string s,s1; int i,flag; map<char,int>mp; mp['B']=mp['F']=mp['P']=mp['V']=1; mp['C']=mp['G']=mp['J']=mp['K']=mp['Q']=mp['S']=mp['X']=mp['Z']=2; mp['D']=mp['T']=3; mp['L']=4; mp['M']=mp['N']=5; mp['R']=6; mp['A']=mp['E']=mp['I']=mp['O']=mp['U']=mp['H']=mp['W']=mp['Y']=0; while(cin>>s) { flag=0; if(mp[s[0]]!=0) { cout<<mp[s[0]]; } for(i=1;i<s.length();i++) { flag=mp[s[i-1]]; if(mp[s[i]]!=flag&&mp[s[i]]!=0) { cout<<mp[s[i]]; } } cout<<endl; }}
0 0
- Soundex(map映射)
- Soundex
- Soundex
- Soundex
- POJ 2608 Soundex(水~)
- 映射map
- Map----映射
- map 映射
- map映射
- C++ map(映射)和multimap(多映射)
- 映射和多重映射(map和multimap)
- 字典(dictionary)与映射(map)
- Hiberante动态处理(MAP映射)
- 凹凸映射(Bump Map)实现原理
- 凹凸映射(Bump Map)实现原理
- Message Map 消息映射(转)
- 凹凸映射(Bump Map)实现原理
- 凹凸映射(Bump Map)实现原理
- 斯坦福《机器学习》Lesson1-3感想-------3、线性回归二
- Unity导出的Android项目按钮无法点击问题
- java基础学习笔记3
- 用java实现音乐的播放
- 调用有道词典查词
- Soundex(map映射)
- 蒙版透明,子视图不透明
- Winsock服务器内存资源管理
- 访问网络图片
- 移动前端头部标签(HTML5 head meta)
- MBProgressHUD的基本使用
- Solr4.10使用教程(二):solr和tomcat整合方法二
- extern 用法,全局变量与头文件(重复定义)
- 统计字符串中出现频率最高的字符