数据是二维数组接收的,不过运行会超时
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt();
String[][] str = new String[N][3];
//键入数据
for (int i = 0; i < str.length; i++) {
str[i][0] = input.next();
str[i][1] = input.next();
str[i][2] = input.next();
}
int M = input.nextInt();
//保存未试机同学的试机号
String[] str1 = new String[M];
for (int i = 0; i < M; i++) {
str1[i] = input.next();
}
//遍历未试机同学的试机号
for (int i = 0; i < str1.length; i++) {
//与原始数据进行对比
for (int j = 0; j < str.length; j++) {
if(str1[i].equals(str[j][1])){
System.out.println(str[j][0]+" "+str[j][2]);
break;
}
}
}
}
}