Quna written test real string decompression
Personal information: studied at Yan University undergraduate software engineering major at present;
I blog: Google search "cqs_2012" can be;
Personal Hobbies: Love data structure and algorithms, hope to work in the future algorithm to make their own contribution to the people;
Programming language: Java;
Programming bad Environment: Windows 8.1 x64;
Programming tools: Eclipse;
Cartographic tools: Office PowerPoint;
Hardware information: ASUS X54HR notebook;
Love situation: In the first kiss in the courtship;
Title: Give a string, such as A1B2C3AB10, to convert it to a abbcccabababababababababab conversion rule, presumably.
Ideas: string extraction, digital extraction
Code: (Java)
Package Wxj_string;public class Main {public static void main (string[] args) {//TODO auto-generated method Stubmain m = n EW Main (); String str = m.strunzip ("A1b2c3ab10"); System.out.println (str);} public string Strunzip (String str) {string result = ""; int i,j;for (i=0;i<str.length ();) {/* * * intercepts the substring containing the letter */for (j=i;; J + +) {if (Str.charat (j) >= ' 0 ' && Str.charat (j) <= ' 9 ') break;} String data = Str.substring (i,j); i = j;/* * intercepts substrings containing numbers */for (j=i;; J + +) {if (J >= str.length () | | | Str.charat (j) < ' 0 ' | | str.charat (j) > ' 9 ') break; String num = str.substring (i,j), i = j;/* * Extract string */int n = integer.parseint (num), for (; n>0;n--) {result + = data;}} return result;}}
Quna written test real string decompression