Fork me on GitHub

牛客网编程练习之去哪儿网2017校招题:身份证分组

image

image

太水了不用思路,直接截取输出就是了....

 

AC代码:

import java.util.Scanner;

/**
 * @author CC11001100
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNextLine()){
			String s = sc.nextLine().replaceAll("\\s+", "");
			if(s.length()>14){
				System.out.printf("%s %s %s\n", s.substring(0, 6), s.substring(6, 14), s.substring(14, s.length()));
			}else if(s.length()>6){
				System.out.printf("%s %s\n", s.substring(0, 6), s.substring(6, s.length()));
			}else{
				System.out.println(s);
			}
		}

	}

}

 

题目来源: https://www.nowcoder.com/practice/58766632a6cc45c0a1158fea2db91728?tpId=85&tqId=29888&tPage=1&rp=1&ru=/ta/2017test&qru=/ta/2017test/question-ranking

 

.

posted @ 2017-12-10 18:05  CC11001100  阅读(220)  评论(0编辑  收藏  举报