题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
import java.util.Scanner;// 注意类名必须为 Main, 不要有任何 package xxx 信息public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); int i = s.length(); int m = i / 8; int n = i % 8; if (m == 0) { for (int l = s.length() - 1; l < 7; l++) { s += "0"; } System.out.println(s); return; } for (int k = 0; k < m; k++) { String s2 = s.substring(k * 8, k * 8 + 8); System.out.println(s2); } String s1 = s.substring(8 * m, s.length()); if(n==0){ return; } for (int k = n; k < 8; k++) { s1 += "0"; } System.out.println(s1); }}