# help with people counting program..

• 06-29-2006
Gong
help with people counting program..
I'm trying to to a simple people counting program.
The scenerio is that is a passageway to a room and i wanted to count how many people going in and how many people going out.

Thank you very much if u can help me..
• 06-29-2006
whiteflags
Well, there are some things that will matter when you write this algorithm:
- how many people will be in the hallway at once?
- who walks the fastest/slowest?
- how long does it take for these people to go from one room to another?
- how many people can be in a room at once?
Answer those questions and work out the algorithm from there.
• 06-30-2006
toonlover
A Little Help
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