Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int minutesToQuit = 2;
- int minutesToEnter = 0;
- queue<Student*> que;
- students.front()->setInQue(minutesToEnter);
- students.front()->setOutOfQue(minutesToQuit);
- que.push(students.front());
- students.pop();
- while (!students.empty()) {
- ++minutesToQuit;
- Student* student = students.front();
- if (minutesToEnter % 2 == 1) {
- student->setInQue(minutesToEnter);
- student->setOutOfQue(minutesToQuit);
- que.push(student);
- queue<Student*> tmp = map.getQueueAtKey(student->getGroupNumber());
- if (!tmp.empty()) {
- while (!tmp.empty()) {
- tmp.front()->setInQue(minutesToEnter);
- tmp.front()->setOutOfQue(minutesToQuit);
- que.push(tmp.front());
- tmp.pop();
- }
- }
- }
- if (minutesToQuit % 2 == 0) {
- students.pop();
- }
- ++minutesToEnter;
- }
- while (!que.empty()) {
- std::cout << que.front()->getName() << " " << que.front()->getOutOfQue() - que.front()->getInQue() << "m\n";
- que.pop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement