POJ 2608 Soundex 基础题题解
来源:互联网 发布:伺服编码器数据乱跳 编辑:程序博客网 时间:2024/06/07 17:58
基本的编程能力考查。
注意:
1 下标处理
2 审查题意,并严格根据题意去重。
3 如何把代码写清晰精简。
#include <stdio.h>#include <string.h>const short MAX_LETTER = 21;const short ALP_LEN = 26;short Letter[ALP_LEN] = {-1, 1, 2, 3, -1, 1, 2, -1, -1, 2, 2, 4, 5, 5, -1, 1, 2, 6, 2, 3, -1, 1, -1, 2, -1, 2};char word[MAX_LETTER];char soundex[MAX_LETTER];int main(){while (gets(word)){short len = strlen(word);short j = 0;for (short i = 0; i < len; ){if (Letter[word[i++]-'A'] != -1){soundex[j++] = Letter[word[i-1]-'A'] + '0';if (i < len){char a = Letter[word[i]-'A'] + '0';while (i < len && a == soundex[j-1]){a = Letter[word[++i]-'A'] + '0';}}}}soundex[j] = '\0';puts(soundex);}return 0;}
1 2
- POJ 2608 Soundex 基础题题解
- poj 2608 Soundex
- poj 2608 Soundex
- POJ 2608 Soundex
- poj 2608 Soundex
- POJ 2608 Soundex G++
- POJ 2608 Soundex(水~)
- POJ 2608 Soundex(我的水题之路——字符值)
- Soundex pku 2608
- Soundex
- Soundex
- Soundex
- SoundEx算法
- C++ Soundex
- ZOJ1858 Soundex
- SOUNDEX(c1)
- soundex算法
- POJ动态规划20题,一句话题解~
- leetcode Palindrome Partitioning
- 2014多校联合-第五场
- js中使用cookie
- 我的Delphi开发经验谈
- oracle导入导出命令,创建用户授权dba 删除用户
- POJ 2608 Soundex 基础题题解
- 关于字符编码,你所需要知道的(转自微信程序猿)
- 习题4-4 骰子涂色 UVa253
- shuipFCMS后台去版权
- RPC简单使用
- 最大开源项目:玩游戏就能学会编程
- js中使用Cookie详解和实例
- js(或jQuery)实用代码段
- CPU时间测试函数