problemscpp
A collection of my answers to algorithm problems in c++.
函数
pat::b::b1004 命名空间参考

1004 成绩排名 更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (b1004, case1)
 

详细描述

1004 成绩排名

函数说明

◆ main()

int pat::b::b1004::main ( istream &  cin,
ostream &  cout 
)

在文件 pat.cpp155 行定义.

155 {
156 int n;
157 cin >> n;
158 vector<tuple<string, string, unsigned short>> vec(n);
159 for(int i = 0; i < n; i++) {
160 string name;
161 string id;
162 int grade;
163 cin >> name >> id >> grade;
164 vec[i] = make_tuple(name, id, grade);
165 }
166 sort(vec.begin(), vec.end(), [](const tuple<string, string, unsigned short> &a, const tuple<string, string, unsigned short> &b) -> bool {
167 const auto &[a_name, a_id, a_grade] = a;
168 const auto &[b_name, b_id, b_grade] = b;
169 return a_grade < b_grade;
170 });
171 auto [highest_name, highest_id, highest_grade] = vec.back();
172 auto [lowest_name, lowest_id, lowest_grade] = vec.front();
173 cout << highest_name << ' ' << highest_id << endl
174 << lowest_name << ' ' << lowest_id;
175 return 0;
176 }
int vec[100010]
Definition: pat.cpp:5095

引用了 pat::a::a7_2::vec.

被这些函数引用 TEST().

◆ TEST()

pat::b::b1004::TEST ( b1004  ,
case1   
)

在文件 pat_test.cpp59 行定义.

59 {
60 istringstream in("3\n"
61 "Joe Math990112 89\n"
62 "Mike CS991301 100\n"
63 "Mary EE990830 95");
64 auto out = ostringstream();
65 main(in, out);
66 const auto ans = out.str();
67 ASSERT_EQ("Mike CS991301\n"
68 "Joe Math990112",
69 ans);
70 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().