牛客网编程练习之去哪儿网2017校招题:身份证分组
太水了不用思路,直接截取输出就是了....
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); } } } }
.