首页 > 其他 > 详细

解密字符串

时间:2015-03-22 00:19:35      阅读:413      评论:0      收藏:0      [点我收藏+]

给一字符串如a2bc3d1 转换成aabcbcbcd

 1   String decode(String str) {
 2         String word="";
 3         StringBuilder result=new StringBuilder("");
 4         for(int i=0;i<str.length();i++)
 5         {
 6             String temp=str.charAt(i)+"";
 7             if(temp.matches("[a-z]"))
 8             {
 9                 result.append(temp);
10                 word+=temp;
11             }
12             else
13             {
14                 int times=Integer.parseInt(temp)-1;
15                 for(int j=0;j<times;j++)
16                     result.append(word);
17                 word="";
18             }
19         }
20         return result.toString();
21         
22     }

 

解密字符串

原文:http://www.cnblogs.com/sweetculiji/p/4356430.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!