题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
暴力解除
import java.lang.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String test = sc.nextLine(); if (test.length() <= 8) { StringBuffer sb = new StringBuffer(); sb.append(test); for (int j = test.length(); j < 8; j++) { sb.append("0"); } System.out.println(sb.toString()); return ; } for (int i = 0; i < test.length(); i+=8) { if (test.length() - i > 8) { String str = test.substring(i, i+8); System.out.println(str); } else { String str = test.substring(i, test.length()); StringBuffer sb = new StringBuffer(); sb.append(str); for (int j = str.length() ; j < 8; j++) { sb.append("0"); } System.out.println(sb.toString()); } } } }#华为OD##华为笔试题#