C++ 面试题翻译电话号码实例代码
例如:
输入:oneTwoThree
输出:123
输入:oneTwoDoubleTwo
输出:1222
输入:1Two2
输出:ERROR
输入:DoubleDoubleTwo
输出:ERROR
有空格,非法字符,两个Double相连,Double位于最后一个单词 都错误。
#include#include using namespace std; void process(string str) { //各字符串的下标即为其对应的阿拉伯数字 char *ch[]={"zero","one","two","three","four","five","six","seven","eight","nine","double"}; char *out[100];//存储结果集 int f=0; int i,j,k; string substr; int len=str.length(); int flag=0;//判断double出现 int flag2=0;//判断内循环有无break for(i=0;i 122)//非字母字符 { out[f++]="error"; break; } else{ //可以看出拼音最短为3个字符,最长为6个字符 for(j=i+2;j 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



