PAT (Basic Level) 1041 考试座位号 (15分)JAVA解法

在这里插入图片描述

输入样例:

4
3310120150912233 2 4
3310120150912119 4 1
3310120150912126 1 3
3310120150912002 3 2
2
3 4

输出样例:

3310120150912002 2
3310120150912119 1

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Reader {
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tokenizer = new StringTokenizer("");
    static String nextLine() throws IOException{// 读取下一行字符串
        return reader.readLine();
    }
    static String next() throws IOException {// 读取下一个字符串
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {// 读取下一个int型数值
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {// 读取下一个double型数值
        return Double.parseDouble(next());
    }
}

public class Main{

    public static void main(String[] args) throws IOException {
        
//      Scanner in = new Scanner(System.in);
        int n1 = Reader.nextInt();
        String[][] data = new String[n1][3];
        
        for ( int i = 0; i < n1; i++ ) {
            for (int j = 0; j < 3; j++ ) {
                data[i][j] = Reader.next();
            }
        }
        
//      for ( String[] d1 : data ) {
//          for ( String d2 : d1 ) {
//              System.out.println(d2);
//          }
//      }
        
        int n2 = Reader.nextInt();
        String[] n = new String[n2];
        for ( int i = 0; i < n2; i++ ) {
            n[i] = Reader.next();
//          System.out.println(n[i]);
        }
        
        
        for ( int i = 0; i < n2; i++ ) {
            for ( int j = 0; j < n1; j++ ) {
                if ( n[i].equals(data[j][1]) ) {
                    System.out.println(data[j][0] +" "+ data[j][2]);
                }
            }
        }
    }
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值