当前位置: 首页> 房产> 市场 > b2b商城网站源码_江西省赣州市中考成绩查询时间_谷歌搜索引擎香港入口_seo流量是什么

b2b商城网站源码_江西省赣州市中考成绩查询时间_谷歌搜索引擎香港入口_seo流量是什么

时间:2025/7/9 2:39:45来源:https://blog.csdn.net/Alsn86/article/details/147565150 浏览次数:0次
b2b商城网站源码_江西省赣州市中考成绩查询时间_谷歌搜索引擎香港入口_seo流量是什么

#PTA - L1-005 考试座位号
优化:
// 使用 BufferedReader:
// BufferedReader 提供了更快的输入速度,尤其是在处理大量数据时。
// 使用 br.readLine() 替代 sc.nextLine()。
// 使用 ArrayList 动态数组:
// ArrayList 可以动态调整大小,避免了固定数组大小限制的问题。
// 使用 Map 提高查询效率:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

//        使用 BufferedReader:
//        BufferedReader 提供了更快的输入速度,尤其是在处理大量数据时。
//        使用 br.readLine() 替代 sc.nextLine()。
//        使用 ArrayList 动态数组:
//        ArrayList 可以动态调整大小,避免了固定数组大小限制的问题。
//        使用 Map 提高查询效率:
//        将座位号和考试信息的映射存储在 HashMap 中,查询的时间复杂度从 O(n) 降低到 O(1)。
//        避免直接访问字段:
//        使用 getter 方法访问类的私有字段,遵循了面向对象编程的封装原则。
//        简化查询逻辑:
//        通过 Map 直接获取查询结果,避免了嵌套循环。import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;class ExamCard {private String _ExamID;private int _tryseat;private int _examseat;public ExamCard() {}public ExamCard(String ExamID, int tryseat, int examseat) {this._ExamID = ExamID;this._tryseat = tryseat;this._examseat = examseat;}public String get_ExamID() {return _ExamID;}public void set_ExamID(String _ExamID) {this._ExamID = _ExamID;}public int get_tryseat() {return _tryseat;}public void set_tryseat(int _tryseat) {this._tryseat = _tryseat;}public int get_examseat() {return _examseat;}public void set_examseat(int _examseat) {this._examseat = _examseat;}
}public class Main {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// 使用 ArrayList 动态数组存储学生信息List<ExamCard> studentInfo = new ArrayList<ExamCard>();// 读取学生数量int student_Num = Integer.parseInt(br.readLine());// 读取每个学生的信息for (int i = 0; i < student_Num; i++) {String each_stu = br.readLine();String[] my_args = each_stu.split(" ");studentInfo.add(new ExamCard(my_args[0], Integer.parseInt(my_args[1]), Integer.parseInt(my_args[2])));}// 使用 Map 存储座位号和考试信息的映射,以提高查询效率Map<Integer, ExamCard> seatMap = new HashMap<>();for (ExamCard stu : studentInfo) {seatMap.put(stu.get_tryseat(), stu);}// 读取查询的学生数量int search_num = Integer.parseInt(br.readLine());// 读取要查询的每个idString str_ids[] = br.readLine().split(" ");// 查询并输出结果for (int i = 0; i < search_num; i++) {int id = Integer.parseInt(str_ids[i]);ExamCard stu = seatMap.get(id);if (stu != null) {System.out.println(stu.get_ExamID() + " " + stu.get_examseat());}}}
}
关键字:b2b商城网站源码_江西省赣州市中考成绩查询时间_谷歌搜索引擎香港入口_seo流量是什么

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: