PAT 考试座位号 Java
作者:互联网
数据是二维数组接收的,不过运行会超时
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;
}
}
}
}
}
标签:Java,String,int,str1,next,str,input,PAT,座位号 来源: https://blog.csdn.net/lshcc01/article/details/123087499