题解 | #动态字符串#
动态字符串
http://www.nowcoder.com/practice/e2c51a6f126b41f9be403376c7adea15
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
//write your code here......
StringBuilder strb=new StringBuilder(str);//String是固定的,StringBuilder和StringBuffer是可变的
for(int i=str.length()-3;i>=0;i-=3)//从最后一个字符串的倒数第三个开始算起,每次往期遍历三个字符
strb.insert(i,",");//在相应的位置插入相应的,即可
System.out.println(strb.toString());
}
}