题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); // 计算要补充的0的个数 int zeroNum = str.length() % 8 == 0 ? 0 : 8 - str.length() % 8; str += String.join("", Collections.nCopies(zeroNum, "0")); for (int i = 0; i < str.length(); i += 8) { System.out.println(str.substring(i, i + 8)); } } }
#华为笔试#