标签:
import java.util.*; public class SplitString { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int M = sc.nextInt(); String []str = new String[M]; for(int i=0; i<M; i++){ str[i] = sc.next(); } for(int i=0; i<M; i++){ if(str[i] != null && str[i].length() != 0) splitStr(str[i]); } } public static void splitStr(String str){ int len = str.length(); if(len == 0) return; if(len <= 8){ System.out.print(str); for(int i = 0; i<8-len; i++){ System.out.print("0"); } System.out.println(); }else{ int remainder = len%8; int quot = len/8; int i = 0; for(; i<quot; i++) System.out.println(str.substring(8*i, 8*(i+1))); if(remainder > 0){ System.out.print(str.substring(8*i, len)); for(int j=0; j<8-remainder;j++){ System.out.print("0"); } System.out.println(); } } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/feige1990/article/details/47807083