本文整理汇总了C++中Course::removeStud方法的典型用法代码示例。如果您正苦于以下问题:C++ Course::removeStud方法的具体用法?C++ Course::removeStud怎么用?C++ Course::removeStud使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::removeStud方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
list<Student*> deferred_acceptance(list<Student*> students,
list<Course*> courses) {
// optimal matching to return
list<Student*> temp;
Course *fav;
Student *stud;
// first iteration
for (auto it = students.begin(); it != students.end(); ++it){
fav = (*it)->getPreferences().front();
if (fav->getNumStuds() < fav->getCapacity()){
(*it)->addCourse(fav);
(fav)->addStudent(*it); // needs to add student into list according to GPA
} else if ((*it)->getGPA() > fav->getLastStud()->getGPA()){
fav->removeStud(); // should return removed student
(*it)->addCourse(fav);
fav->addStudent(*it); // ditto ^^^^
}
(*it)->removePref(); // removes the first preference
}
for (auto it = students.begin(); it != students.end(); ++it){
if ((*it)->getCourses().size() == 5) (*it)->is_full = true;
else (*it)->is_full = false;
if ((*it)->getPreferences().empty()) (*it)->is_full = true;
if (!(*it)->is_full){
temp.push_front(*it);
}
}
// here we go
while (temp.size() > 0){
for (auto it = temp.begin(); it != temp.end();){
fav = (*it)->getPreferences().front();
if (fav->getNumStuds() < fav->getCapacity()){
(*it)->addCourse(fav);
(fav)->addStudent(*it);
if ((*it)->getCourses().size() == 5) (*it)->is_full = true;
} else if ((*it)->getGPA() > fav->getLastStud()->getGPA()){
stud = fav->removeStud();
stud->removeCourses(fav);
stud->is_full = false;
fav->addStudent(*it);
(*it)->addCourse(fav);
if ((*it)->getCourses().size() == 5) (*it)->is_full = true;
}
(*it)->removePref();
if ((*it)->getPreferences().empty()) (*it)->is_full = true;
if ((*it)->is_full) temp.remove(*it++);
else ++it;
}
}
return students;
}