题解 | #字符串分隔#

字符串分隔

http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7

import java.util.Scanner;

public class Main{
    
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String s = sc.nextLine();
            splitStr(s);
        }
    }
    
    public static void splitStr(String str){
        String temp = "00000000";
        String result = "";
        for(int i = 0;i<=(str.length()-1)/8;i++){
            int s = i * 8;
            int e = (i+1) * 8;
            if(e>str.length()-1){
                String st = str.substring(s)+temp;
                result = st.substring(0,8);
            }else{
                result = str.substring(s,e);
            }
            System.out.println(result);
        }
    }
}
全部评论

相关推荐

点赞 评论 收藏
分享
05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求...:注意把武大标粗标大 本地你俩不是乱杀
实习进度记录
点赞 评论 收藏
分享
昨天 11:42
江西农业大学 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务