diff options
| author | Carlos Maiolino <[email protected]> | 2025-09-06 09:37:14 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-09-06 09:37:14 +0200 |
| commit | 2c9056a23e1a55fd21a8e314c903d9325bffd62e (patch) | |
| tree | a73ba1c7bb60dd89c9e70769dd510e59a49a56a1 /CPP/cpp_book/chap5/approval.cpp | |
| parent | ee8a08bfa24d9a3d09273fdebe8d73ac38c545f9 (diff) | |
Move CPP code here
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'CPP/cpp_book/chap5/approval.cpp')
| -rw-r--r-- | CPP/cpp_book/chap5/approval.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/CPP/cpp_book/chap5/approval.cpp b/CPP/cpp_book/chap5/approval.cpp new file mode 100644 index 0000000..c31c7b5 --- /dev/null +++ b/CPP/cpp_book/chap5/approval.cpp @@ -0,0 +1,28 @@ +#include <vector> +#include <iostream> +#include "student_info.h" +#include "grade.h" +#include "approval.h" + +bool fgrade(const StudentInfo& s) { + return grade(s) < 60; +} + +std::list<StudentInfo> +extract_fails( + std::list<StudentInfo>& students) +{ + std::list<StudentInfo> fail; + std::list<StudentInfo>::iterator iter = students.begin(); + + while (iter != students.end()) { + if (fgrade(*iter)) { + fail.push_back(*iter); + iter = students.erase(iter); + } else { + iter++; + } + } + + return fail; +} |
