Scanner cin=new Scanner(System.in);HashMap<String, Integer> hashMap=new HashMap<>();hashMap.put("yi", 1);hashMap.put("er", 2);hashMap.put("san", 3);hashMap.put("si", 4);hashMap.put("wu", 5);hashMap.put("liu", 6);hashMap.put("qi", 7);hashMap.put("ba", 8);hashMap.put("jiu", 9);
while(cin.hasNext()){
func(hashMap, cin.next());
break;
}
int k1=0;int k2=2;//System.out.println(hashMap.get("111"));while(k2<=str.length()){
if (hashMap.get(str.subSequence(k1, k2))!=null){
System.out.print(hashMap.get(str.subSequence(k1, k2)));
}else {
k2++;
if (hashMap.get(str.subSequence(k1, k2))!=null)
{
System.out.print(hashMap.get(str.subSequence(k1, k2)));
}
}
k1=k2;
k2+=2;
}}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/lyric_315/article/details/47656589