题解 | #字符串分隔#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
简单做法:
/*@author: xbd
*/
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int cnt = (8 - str.length() % 8) % 8;
StringBuilder sb = new StringBuilder(str);
while(sb.length() > 8){
System.out.println(sb.substring(0,8));
sb.delete(0, 8);
}
if(sb.length() != 0 && sb.length() != 8)
while(cnt-- != 0)
sb.append('0');
System.out.println(sb.toString());
}
}