### Simulation program

I'm making a simulation for severals queues. I'm supposed to input number of queues in the beginning and then simulate all thoose.

Output for each queue each "round" is meantime, total number of served and size of each queue.

My program is crashing and dosen't respond.

It writes out the first queue och then crashes...

Help!

I think my calculations is wrong to but i don't know since it's all crashing.
I think the problem is my last for loop.

Here it is:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150`` ``````#include #include #include #include #include #include #include using namespace std; class Customer { public: int servicet; int served; Customer() { servicet= rand()%150+30; } int getServicetime() { return servicet; } int getServed() { return served; } int decreaseServeTime() { servicet --; } }; int totServed=0; int queues=0; int inLine=0; int totTime=0; int smallestQueue=0; int temp=0; int ran=0; double mean=0; int served=0; int serviceTime=0; int help=0; int sim=0; int n=0; using namespace std; int main() { cout<<"Number of Cashiers?: "<> queues; cout <<"How long simulation?: "<> sim; list *cashiers[queues]; list *cust; for(int i=0; i<=queues; i++) { cust = new list; cashiers[i] = cust; } srand(time(0)); while(nsize(); for(int j=0; jsize(); if(temp<=smallestQueue) { smallestQueue = temp; help=k; } } Customer C; cashiers[help]->push_back(C); inLine++; } for(int i=0; i0) { serviceTime = cashiers[i]->front().getServicetime(); cashiers[i]->front().decreaseServeTime(); } else if(serviceTime==0) { cashiers[i]->pop_front(); served++; } } totTime++; int cash=1; for(int i=0; isize(); mean = (totTime/inLine); totServed +=served; cash++; cout <<"In this line: "<
Topic archived. No new replies allowed.