1041 考试座位号

时间:2020-02-19 18:30:58   收藏:0   阅读:37

水题。发现PAT考察hash很多。

#include<iostream>
#include<unordered_map>
using namespace std;

struct Student {
    string id;//学号 
    int sitNum;//考试座位号 
};
int main() {
    int n,index;//试机座位号
    Student stu;
    cin>>n;
    unordered_map<int,Student> mp;//建立试机座位号,与学生信息(id和考试座位号)的映射关系 
    for(int i = 0; i < n; ++i) {
        cin>>stu.id>>index>>stu.sitNum;
        mp[index] = stu;
    }
    cin>>n;
    while(n--) {
        cin>>index;
        cout<<mp[index].id<<" "<<mp[index].sitNum<<endl;
    }
    return 0;
}

技术分享图片

 

原文:https://www.cnblogs.com/keep23456/p/12332326.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!