您的位置:首页 > 编程语言

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

2017-12-10 18:05 405 查看

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

 

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

 

.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: