题目描述:
输入:输入某人的18位身份证号,输出其出生日期。
输出:多实例测试。首先输入一个整数n,表示测试实例的个数,然后是n行,每行是一个18位身份证号。
样例输入:对于输入的每个身份证号,输出一行,即其对应的出生日期,输出格式为:yyyy-mm-dd。
样例输出:3
410106199411178657
410104198202095479
410122197911218097
程序代码:1994-11-17
1982-02-09
1979-11-21
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int t=input.nextInt();
char [] ch=new char[18];
String str;
for(int i=1;i<=t;i++)
{
str=input.next();
for(int j=0;j<18;j++)
ch[j]=str.charAt(j);
System.out.print(ch[6]+""+ch[7]+""+ch[8]+""+ch[9]+"-");
System.out.print(ch[10]+""+ch[11]+"-");
System.out.println(ch[12]+""+ch[13]);
}//在其中间加入空字符是为了将字符分隔开,避免重合相加,因为程序会把字符对应的ASCII码相加
input.close();
}
}