Hello, I saw your post and prepared this code for you , it's not complete yet, but it is up to you to finish the simulation of the counting:
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
#define _IN 200 //STATUS GOING IN
#define _OUT 201 //STATUS GOING OUT
#define _STAY 300 //STATUS ON THE ROOM
using namespace std;
const int iPeople = 100; //# of People
const int iSTAYallowed = 75; //Max allowed to STAY
void Start(); //Initialize Random Speeds
void Simulation(void); //Simulation
void Update(); //Update to the Display
struct Person //The person(s)
{
int speed;
int status;
}People[iPeople];
struct _Display //Update Status
{
int iPeoIn;
int iPeoOut;
int iPeoStay;
}Display;
int main()
{
Start();
cout<<"\nPress [Enter] to start Simulation\n"<<endl;
cin.get();
Simulation();
system("PAUSE");
return 0; //or exit(0);
}
void Simulation(void)
{
/*
CODE HERE:
*/
}
void inline Update()
{
int in =0,
out=0,
stay=0;
for(int x=0; x<=iPeople; x++)
{
if(People[x].status == _OUT)
{
out++;
}
if(People[x].status == _IN)
{
in++;
}
if(People[x].status == _STAY)
{
stay++;
}
Display.iPeoIn = in;
Display.iPeoOut = out;
Display.iPeoStay = stay;
}
}
void Start()
{
srand( (unsigned) time(NULL) ); //Random Seed
for(int x=0; x<=iPeople; x++) //Assinging Speeds and Status
{
People[x].speed = rand()%5000;
People[x].status = _OUT;
}
}
I already declared almost everything that you need, hope it helps