// 只需计算第一组字符串的长度,之后每一组的长度都是3 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.next(); //write your code here...... int strlen=str.length(); int k=strlen % 3; int i=0; while(i<strlen){ String s=str.substring(i,i+k); System.out.print(s); i+=k; if(i<strlen){ System.out.print(","); } k=3; } } }