poj 2608 soundx

//注意重复的或者其soundx值相等的字符应该先去掉! 
#include <iostream>
#include <string>
#include <map>
using namespace std;

map<char, int> m;

int main()
{
    m['B'] = 1, m['F'] = 1, m['P'] = 1, m['V'] = 1;
    m['C'] = 2, m['G'] = 2, m['J'] = 2, m['K'] = 2, m['Q'] = 2, m['S'] = 2, m['X'] = 2, m['Z'] = 2;
    m['D'] = 3, m['T'] = 3;
    m['L'] = 4;
    m['M'] = 5, m['N'] = 5;
    m['R'] = 6;
    string str1, str2, ans;
    int len, i;
    while (cin >> str1){
          len = str1.length();
          str2.clear();
          ans.clear();
          //将重复的字符进行删除 
          for (i = 0; i < len; i++){
              str2.push_back(str1[i]);
              while ((str1[i] == str1[i+1]) || (m[str1[i]] == m[str1[i+1]])) i++;
          }
          len = str2.length();
          for (i = 0; i < len; i++){
              if (str2[i] == 'A' || str2[i] == 'E' || str2[i] == 'I' || str2[i] == 'O' || str2[i] == 'U' || str2[i] == 'H' || str2[i] == 'W' || str2[i] == 'Y')
                  continue;
              else
                  ans.push_back(m[str2[i]]+48); 
          }
          cout << ans << endl;
    }
    
    system("pause");
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值