nt = rv.current: ttime = rv.tt
Автор admin
Вторник, 9 июня 2009 11:32
nt = rv.current: ttime = rv.ttime: busy = rv.busy: 380 Глава 7 • Обобщенные контейнеры // Наследование для обращения к защищенной реализации: class CustomerQ : public queue { public: friend ostream& operator«(ostream& os. const CustomerQS cd) { copy(cd.c.beginO. cd.c.endO, ostream_iterator(os. “”)): return os; } }: int mainO { CustomerQ customers: list tellers; typedef list::iterator Tel lit: tel 1 ers.push_back(Tel1er(customers)); srand(time(0)): // Раскрутка генератора случайных чисел clock_t ticks = clockO: // Запуск имитации минимум на 5 секунд: while(clock() < ticks + 5 * CLOCKS_PER_SEC) { // Заполнение очереди случайным количеством клиентов // со случайным временем обслуживания: for(int i = 0; i < randO % 5; i++) customers.push(Customer(randО % 15 + 1)); cout « '{' « tell ers. sizeO « '}' « customers « endl; // Обслуживание клиентов: return *this; } bool isBusyO { return busy; } void run(bool recursion = false) { if(!recursion) ttime = SLICE: int servtime = current.getTime(); if(servtime > ttime) { servtime -= ttime: current.setTime(servtime); busy = true; //
Комментарии закрыты.
Последние комментарии