#include #include #include #include using namespace std; class task { public: task(string const& s, int t) : name(s), wcet(t) {} string get_name() const { return name;} int dec_wcet() { return --wcet;} bool operator<(task const& t) const { return wcet < t.wcet; } bool operator==(task const& t) const { return wcet < t.wcet; } private: string name; int wcet; }; int main() { vector readylist; int time = 0; do { string name; do { cout << "Enter new task arriving at day " << time << ": "; getline(cin, name); if ( name.size() > 0 ) { int wcet; cout << "Days needed for completion: "; cin >> wcet; cin.ignore(1024, '\n'); readylist.push_back( task(name, wcet) ); } } while (name.size() > 0); sort(readylist.rbegin(), readylist.rend()); cout << "Day " << time << ": Today you should work on ==================> " << readylist.back().get_name() << endl; if ( readylist.back().dec_wcet() == 0 ) readylist.pop_back(); ++time; } while ( readylist.size() > 0 ); return 0; }