题解 | #明明的随机数#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
import java.util.*;
public class Main {
public static void main(String[] a) {
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
int n = (int)Math.floor(s1.length() / 8);
for (int i = 0 ; i < n ; i++) {
System.out.println(s1.substring(i * 8, (i + 1) * 8));
}
if (s1.length() % 8 != 0) {
int m = (n + 1) * 8 - s1.length();
String s2 = s1.substring(n * 8, s1.length());
for (int j = 0 ; j < m ; j ++) {
s2 += "0";
}
System.out.print(s2);
}
}
}
public class Main {
public static void main(String[] a) {
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
int n = (int)Math.floor(s1.length() / 8);
for (int i = 0 ; i < n ; i++) {
System.out.println(s1.substring(i * 8, (i + 1) * 8));
}
if (s1.length() % 8 != 0) {
int m = (n + 1) * 8 - s1.length();
String s2 = s1.substring(n * 8, s1.length());
for (int j = 0 ; j < m ; j ++) {
s2 += "0";
}
System.out.print(s2);
}
}
}