//注意重复的或者其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");
}
poj 2608 soundx
最新推荐文章于 2022-02-25 23:45:16 发布