// PATn.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<tuple>
#include<vector>
#include<memory>
using namespace std;
class Stu_info
{
public:
Stu_info() :data(make_shared<vector<tuple<string, unsigned, unsigned>>>()) {}
Stu_info insert(string &s, unsigned m, unsigned n) { insert_info(s, m, n); return *this; }
tuple<string, unsigned, unsigned> find(unsigned m) { return find_num(m); }
private:
shared_ptr<vector<tuple<string, unsigned, unsigned>>> data;
void insert_info(string &s, unsigned m, unsigned n);
tuple<string, unsigned, unsigned> find_num(unsigned m);
};
void Stu_info::insert_info(string &s, unsigned m, unsigned n)
{
tuple<string, unsigned, unsigned> tmp = make_tuple(s, m, n);
data->push_back(tmp);
}
tuple<string, unsigned, unsigned> Stu_info::find_num(unsigned m)
{
for (auto r : (*data))
{
if (get<1>(r) == m)
{
return r;
}
}
}
int main()
{
unsigned n;
cin >> n;
string tmp1;
unsigned tmp2, tmp3;
Stu_info data;
for (unsigned i = 0; i < n; ++i)
{
cin >> tmp1 >> tmp2 >> tmp3;
data.insert(tmp1, tmp2, tmp3);
}
unsigned m;
cin >> m;
unsigned tmp_find;
for (unsigned j = 0; j < m; ++j)
{
cin >> tmp_find;
auto find_result = data.find(tmp_find);
cout << get<0>(find_result) << " " << get<2>(find_result);
if (j != (m - 1))
{
cout << endl;
}
}
system("pause");
return 0;
}
网友评论