problemscpp
A collection of my answers to algorithm problems in c++.
| 类型定义 | 函数
acwing::acwing3376 命名空间参考

struct  student
 

类型定义

typedef struct acwing::acwing3376::student student
 

函数

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

类型定义说明

◆ student

函数说明

◆ main()

int acwing::acwing3376::main ( istream &  cin,
ostream &  cout 
)

在文件 acwing408.cpp54 行定义.

54 {
55 int n;
56 cin >> n;
57 vector<student> students(n);
58 for(int i = 0; i < n; i++) {
59 cin >> students[i].id >> students[i].score;
60 students[i].id_numeric = stoi(students[i].id);
61 }
62 sort(students.begin(), students.end(), [](const student &a, const student &b) {
63 if(a.score == b.score) {
64 return a.id_numeric < b.id_numeric;
65 }
66 return a.score < b.score;
67 });
68 for(const auto &s: students) {
69 cout << s.id << ' ' << s.score << endl;
70 }
71 return 0;
72 }
struct acwing::acwing3378::student student

引用了 acwing::acwing3376::student::score.

被这些函数引用 TEST().

◆ TEST()

acwing::acwing3376::TEST ( acwing3376  ,
case1   
)

在文件 acwing408_test.cpp463 行定义.

463 {
464 istringstream in("3\n"
465 "1 90\n"
466 "2 87\n"
467 "3 92");
468 auto out = ostringstream();
469 main(in, out);
470 const auto ans = out.str();
471 ASSERT_EQ("2 87\n"
472 "1 90\n"
473 "3 92\n",
474 ans);
475 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().