|
-
December 29th, 2011, 02:28 PM
#16
Re: Java Challenge
try this one.......
public class Problemconverter {
public static void convert(String s){
int len = s.length();
String next;
int count = 1;
if (len == 0)
return ;
else if(len == 1)
System.out.println(count+""+s.charAt(0));
else{
for(int i=0; i<len; i++){
if(s.charAt(i) == s.charAt(i+1)){
count++;
}
else break;
}
System.out.print(count+""+s.charAt(0));
next = s.substring(count);
convert(next);
}
}
public static void main(String[] args) {
convert("10444221");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|