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

1077 互评成绩计算 更多...

函数

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

详细描述

1077 互评成绩计算

函数说明

◆ main()

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

在文件 pat.cpp2736 行定义.

2736 {
2737 int n;
2738 int m;
2739 cin >> n >> m;
2740 for(int i = 0; i < n; i++) {
2741 int s_teacher;
2742 cin >> s_teacher;
2743 vector<int> scores;
2744 for(int j = 1; j < n; j++) {
2745 int score;
2746 cin >> score;
2747 if(0 <= score && score <= m) {
2748 scores.push_back(score);
2749 }
2750 }
2751 sort(scores.begin(), scores.end());
2752 scores.erase(scores.begin());
2753 scores.erase(--scores.end());
2754 int sum = 0;
2755 for(int j = 0; j < scores.size(); j++) {
2756 sum += scores[j];
2757 }
2758 const double avg = static_cast<double>(sum) / scores.size();
2759 const int final = static_cast<int>((avg + s_teacher) / 2 + 0.5);
2760 cout << final << endl;
2761 }
2762 return 0;
2763 }

被这些函数引用 TEST().

◆ TEST()

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

在文件 pat_test.cpp1308 行定义.

1308 {
1309 istringstream in("6 50\n"
1310 "42 49 49 35 38 41\n"
1311 "36 51 50 28 -1 30\n"
1312 "40 36 41 33 47 49\n"
1313 "30 250 -25 27 45 31\n"
1314 "48 0 0 50 50 1234\n"
1315 "43 41 36 29 42 29");
1316 auto out = ostringstream();
1317 main(in, out);
1318 const auto ans = out.str();
1319 ASSERT_EQ("42\n"
1320 "33\n"
1321 "41\n"
1322 "31\n"
1323 "37\n"
1324 "39\n",
1325 out.str());
1326 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().